ORA-00904 when inserting/querying data from tables

谁说我不能喝 提交于 2019-12-04 17:23:28

Seems like you specified the column names under quotes in your DDL.

Oracle considers identifiers under quotes as a case sensitive, so creating a table with a column name as "body" or "year" will not resolve body or year in your query, because when you omit the quotes, it considers the upper case variant.

So when you have this:

 create table driver_case (registration varchar2(60), 
                      make varchar2(60),
                      model varchar2(60),
                      gvw number,
                      "year" number, 
                      "body" varchar2(60));

and then try to do

select year, body from driver_case

then Oracle tries to find column "YEAR", "BODY" (remember, without an identifier without quotes gets converted to upper case) which is not the same as "year", "body" in your table.

Your solutions?

  • Don't mention column names under quotes in the DDL
  • If you disregard the above point, then you must mention the column names under quotes in all your DML statements.

I demonstrate the above point in this SQL Fiddle

Ashish Kumar jain

Try this:

INSERT
    WHEN city='palanpur' THEN INTO Ashish 
    When city='Aburoad' THEN INTO abhi
SELECT no, name
    FROM arpit;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!