隐式插入语句

时间:2013-04-04 20:45:55

标签: oracle

我在将某些值插入表的副本时遇到问题。这是我的代码:

INSERT INTO copy_d_events
VALUES (110, 'Ayako Anniversary',
        07-Jul-04, 
        'Party for 50, sixties dress, decorations', 
        'Not Determined', 
        245, 79, 240, 6655);

Oracle给了我这个错误:

  

ORA-00984:此处不允许列

任何人帮助一个人出去?

@TheEwook我也尝试过:

INSERT INTO copy_d_events
(ID, Name, Event_ Date, Description, Cost, Venue_ID, Package_ Code ,Theme_Code ,Client_ Number) VALUES (110, 'Ayako Anniversary',07-Jul-04,'Party for 50, sixties dress, decorations',245, 79, 240, 6655);

2 个答案:

答案 0 :(得分:4)

日期07-Jul-04存在问题。你不能只写这样的日期。

您可以尝试使用to_date功能:

INSERT INTO copy_d_events
VALUES (110, 'Ayako Anniversary',to_date('01/07/2004','dd/mm/yyyy'), 'Party for 50, sixties dress, decorations', 'Not Determined', 245, 79, 240, 6655);

强烈建议在数据库中插入数据时指定列名。

INSERT INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)

Doc:http://www.w3schools.com/sql/sql_insert.asp

答案 1 :(得分:0)

尝试使用to_date功能:

INSERT INTO copy_d_events
VALUES (110, 'Ayako Anniversary',
        to_date('2004/07/07 00:00:00', 'yyyy/mm/dd hh24:mi:ss'), 
        'Party for 50, sixties dress, decorations', 
        'Not Determined', 
        245, 79, 240, 6655);
  

to_date功能允许您定义日期/时间的格式   值

修改

ID  NAME                EVENT_DATE  DESCRIPTION                             COST     VENUE_ID PACKAGE_CODE  THEME_CODE CLIENT_NUMBER 
100 Peters Graduation   14-MAY-04   Party for 200, red, white, blue motif   8000    100 112 200 5922 105    Vigil wedding   28-APR-04   Black tie at Four Season hotel  10000   220 200 200 6133

根据您发布的列数据,我认为问题是'Not Determined'值。如果它是数字列,您可能需要以这种方式查询:

INSERT INTO copy_d_events
VALUES (110, 'Ayako Anniversary',
        to_date('2004/07/07 00:00:00', 'yyyy/mm/dd hh24:mi:ss'), 
        'Party for 50, sixties dress, decorations', 
        0, 
        245, 79, 240, 6655);