oracle express 11g exception weird

走远了吗. 提交于 2019-12-25 06:46:20

问题


CREATE TABLE  "EMPLOYEE" 
("SSN" NUMBER(*,0) NOT NULL ENABLE, 
 "MANAGER_SSN" NUMBER(*,0) NOT NULL ENABLE, 
 "STREET" CHAR(40) NOT NULL ENABLE, 
 "CITY" CHAR(25) NOT NULL ENABLE, 
 "DEP_NO" NUMBER(*,0) NOT NULL ENABLE, 
 "NAME" CHAR(15) NOT NULL ENABLE, 
 "SALARY" NUMBER(8,2) NOT NULL ENABLE, 
 "HIRE_DATE" DATE, 
 CONSTRAINT "PK_EMPLOYEE" PRIMARY KEY ("SSN") ENABLE
)

and when i try to insert into that table :

insert into employee values (1,1,"cola","beirut",1,"mohamad",1500,"7-feb-1999")

it says : ORA-00984: column not allowed here what the hell is this !!!!! why this error is happening " it is not a matter of small or capital letter "


回答1:


There seem to be two separate problems;

  • You need to quote literal strings with ' in Oracle, double quotes are used for quoting object names for case sensitivity.
  • Your database does not seem to use the 7-Feb-1999 date format by default, so you'll have to tell it which format you're using.

All in all, the query should be;

INSERT INTO employee 
  VALUES (1, 1, 'cola', 'beirut', 1, 'mohamad', 1500, 
          TO_DATE('7-feb-1999', 'DD-MON-YYYY'));

An SQLfiddle to test with.




回答2:


In Oracle, varchar literals are marked by single quote ('), not double quotes ("). Double quotes denote case-sensitive object names, such as columns.

Just switch your double quotes to single quotes and you'll be fine:

insert into employee values (1,1,'cola','beirut',1,'mohamad',1500,'7-feb-1999')


来源:https://stackoverflow.com/questions/20776231/oracle-express-11g-exception-weird

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!