I created this table called LOCATION by doing this:
CREATE TABLE LOCATION(
POSTCODE VARCHAR(10) PRIMARY KEY,
STREET_NAME VARCHAR(20),
CITY VARCHAR(20));
Try using varchar2 instead of varchar and use this :
INSERT INTO LOCATION VALUES('PQ95VM','HAPPY_STREET','FRANCE');
What you missed is " "
in postcode because it is a varchar
.
There are two ways of inserting.
When you created a table Table created.
and you add a row just after creating it, you can use the following method.
INSERT INTO table_name
VALUES (value1,value2,value3,...);
1 row created.
You've added so many tables, or it is saved and you are reopening it, you need to mention the table's column name too or else it will display the same error.
ERROR at line 2:
ORA-00984: column not allowed here
INSERT INTO table_name (column1,column2,column3,...)
VALUES (value1,value2,value3,...);
1 row created.
INSERT INTO LOCATION VALUES(PQ95VM,'HAPPY_STREET','FRANCE');
the above mentioned code is not correct because your first parameter POSTCODE is of type VARCHAR(10)
. you should have used ' '
.
try INSERT INTO LOCATION VALUES('PQ95VM','HAPPY_STREET','FRANCE');
Some time, While executing insert query, we are facing:
Column not allowed here
error. Because of quote might missing in the string parameters. Add quote in the string params and try to execute.
Try this:
INSERT INTO LOCATION VALUES('PQ95VM','HAPPY_STREET','FRANCE');
or
INSERT INTO LOCATION (ID, FIRST_NAME, LAST_NAME) VALUES('PQ95VM','HAPPY_STREET','FRANCE');
http://www.drtuts.com/oracle-error-column-not-allowed-here/
Scanner sc = new Scanner(System.in);
String name = sc.nextLine();
String surname = sc.nextLine();
Statement statement = connection.createStatement();
String query = "INSERT INTO STUDENT VALUES("+'"name"'+","+'"surname"'+")";
statement.executeQuery();
Do not miss to add '"----"' when concat the string.
This error creeps in if we make some spelling mistake in entering the variable name. Like in stored proc, I have the variable name x and in my insert statement I am using
insert into tablename values(y);
It will throw an error column not allowed here.