我使用以下查询将多行插入表my_employee
:
insert all into
my_employee (id, last_name, first_name, userid, salary) values (&id, '&last_name', '&firstname', '&userid', &salary)
my_employee (id, last_name, first_name, userid, salary) values (&id, '&last_name', '&firstname', '&userid', &salary)
my_employee (id, last_name, first_name, userid, salary) values (&id, '&last_name', '&firstname', '&userid', &salary)
select * from DUAL;
然而我一步一步地跟着类似的问题,但我不知道为什么我会收到这个错误:
Erreur SQL : ORA-00928: missing SELECT keyword
00928. 00000 - "missing SELECT keyword"
答案 0 :(得分:2)
您需要为每个插入指定into
。这应该有效:
insert all
into my_employee (id, last_name, first_name, userid, salary) values (&id, '&last_name', '&firstname', '&userid', &salary)
into my_employee (id, last_name, first_name, userid, salary) values (&id, '&last_name', '&firstname', '&userid', &salary)
into my_employee (id, last_name, first_name, userid, salary) values (&id, '&last_name', '&firstname', '&userid', &salary)
select * from DUAL;
答案 1 :(得分:1)
您可以使用三个插入语句执行此操作:
insert into my_employee (id, last_name, first_name, userid, salary)
values (&id, '&last_name', '&firstname', '&userid', &salary);
insert into my_employee (id, last_name, first_name, userid, salary)
values (&id, '&last_name', '&firstname', '&userid', &salary);
insert into my_employee (id, last_name, first_name, userid, salary)
values (&id, '&last_name', '&firstname', '&userid', &salary);
或使用union all
的一个声明:
insert into my_employee (id, last_name, first_name, userid, salary)
select &id, '&last_name', '&firstname', '&userid', &salary
from dual union all
select &id, '&last_name', '&firstname', '&userid', &salary
from dual union all
select &id, '&last_name', '&firstname', '&userid', &salary;
我没有看到insert all
的申请,因为你想插入一张表。
答案 2 :(得分:1)
在MSSQL中
insert into my_employee (id, last_name, first_name, userid, salary)
values (&id, '&last_name', '&firstname', '&userid', &salary)
go 100;
它将插入具有相同值的100行