CREATE TABLE dw.D_DAYLIGHT_SAVINGS
(
DAYLIGHT_YEAR INTEGER NOT NULL,
DAYLIGHT_START DATE,
DAYLIGHT_END DATE,
Last_Udpated_date DATE DEFAULT SYSDATE,
Last_updated_user VARCHAR2 (25) DEFAULT 'DW'
);
表已创建,但是当我尝试在TOAD中运行并在其中插入值时,错误弹出,因为命令未正确结束。插入的查询如下
insert into dw.D_DAYLIGHT_SAVINGS values
(2013,'March 10','November 3'),
(2014,'March 9','November 2'),
(2015,'March 8','November 1'),
(2016,'March 13','November 6'),
(2017,'March 12','November 5');
答案 0 :(得分:0)
每行必须有一个单独的INSERT INTO
语句,并为未指定的每列添加DEFAULT
:
insert into dw.D_DAYLIGHT_SAVINGS values (2013,'March 10','November 3', DEFAULT, DEFAULT);
insert into dw.D_DAYLIGHT_SAVINGS values (2014,'March 9','November 2', DEFAULT, DEFAULT);
insert into dw.D_DAYLIGHT_SAVINGS values (2015,'March 8','November 1', DEFAULT, DEFAULT);
insert into dw.D_DAYLIGHT_SAVINGS values (2016,'March 13','November 6', DEFAULT, DEFAULT);
insert into dw.D_DAYLIGHT_SAVINGS values (2017,'March 12','November 5', DEFAULT, DEFAULT);
或提供应插入列的列的列表:
insert into dw.D_DAYLIGHT_SAVINGS (DAYLIGHT_YEAR, DAYLIGHT_START, DAYLIGHT_END) values (2013,'March 10','November 3');
insert into dw.D_DAYLIGHT_SAVINGS (DAYLIGHT_YEAR, DAYLIGHT_START, DAYLIGHT_END) values (2014,'March 9','November 2');
insert into dw.D_DAYLIGHT_SAVINGS (DAYLIGHT_YEAR, DAYLIGHT_START, DAYLIGHT_END) values (2015,'March 8','November 1');
insert into dw.D_DAYLIGHT_SAVINGS (DAYLIGHT_YEAR, DAYLIGHT_START, DAYLIGHT_END) values (2016,'March 13','November 6');
insert into dw.D_DAYLIGHT_SAVINGS (DAYLIGHT_YEAR, DAYLIGHT_START, DAYLIGHT_END) values (2017,'March 12','November 5');
答案 1 :(得分:0)
如果要使用单个INSERT语句,请查看INSERT ALL / FROM DUAL语句: Best way to do multi-row insert in Oracle?