插入错误sql-developer

时间:2013-10-14 21:19:25

标签: oracle oracle-sqldeveloper

我正在尝试将数据插入表中:

INSERT INTO CIVILSTATUS
  (CivilStatusID, CivilStatusDesc)
VALUES (1, 'Single'),
       (2, 'Married'),
       (3, 'Separate'),
       (4, 'Widower');

但是我收到了这个错误:

Error SQL: ORA-00933: comand SQL not properly ended
00933. 00000 -  "SQL command not properly ended"

我做得对,或者我的语法有错误?

3 个答案:

答案 0 :(得分:1)

我会将其改写如下

INSERT ALL 
INTO CIVILSTATUS (CivilStatusID, CivilStatusDesc) VALUES (1, 'Single')
INTO CIVILSTATUS (CivilStatusID, CivilStatusDesc) VALUES (2, 'Married')
INTO CIVILSTATUS (CivilStatusID, CivilStatusDesc) VALUES (3, 'Separate')
INTO CIVILSTATUS (CivilStatusID, CivilStatusDesc) VALUES (4, 'Widower')
SELECT * FROM CIVILSTATUS

答案 1 :(得分:0)

使用以下语法:

INSERT ALL
   INTO CIVILSTATUS (CivilStatusID, CivilStatusDesc) VALUES (1, 'Single')
   INTO CIVILSTATUS (CivilStatusID, CivilStatusDesc) VALUES (2, 'Married')
   INTO CIVILSTATUS (CivilStatusID, CivilStatusDesc) VALUES (3, 'Separate')
   INTO CIVILSTATUS (CivilStatusID, CivilStatusDesc) VALUES (4, 'Widower')
   .
   .
   .
SELECT 1 FROM DUAL;

答案 2 :(得分:0)

对于多行,您需要使用select,如下所示:

insert into civilstatus
(CivilStatusID, CivilStatusDesc)
select 2, 'Married' from dual
union all select 3, 'Separate' from dual;