我已成功使用此命令创建表
create table Person(
first_name varchar(25) not null,
last_name varchar(25) not null,
persoin_id number not null,
birth_date date,
country varchar (25),
salary number);
现在我想在该表中插入数据
insert into Person(persoin_id,first_name,last_name,salary,birth_date,country)
values(100,'dato','datuashvili',350,to_date('01/01/10','DD/MM/YY'),'georgia');
values(101,'irakli','oqruashvili',350,to_date('01/03/10','DD/MM/YY'),'georgia');
插入第一行,但问题是第二行
1 rows inserted.
在命令的第10行开始出错:
值(101, '伊拉克利梅', 'oqruashvili',350,TO_DATE('01 / 03 / 10' , 'DD / MM / YY'), '格鲁吉亚')
错误报告:
未知命令
请帮我确定问题是什么?谢谢
答案 0 :(得分:6)
如果您使用的是支持多行插入的RDBMS INSERT
:
insert into Person(persoin_id,first_name,last_name,salary,birth_date,country)
values
(100,'dato','datuashvili',350,to_date('01/01/10','DD/MM/YY'),'georgia') ,
--- comma here ---^
(101,'irakli','oqruashvili',350,to_date('01/03/10','DD/MM/YY'),'georgia') ;
^--- no "values" here
如果不是(如Oracle),则必须发出两个插入语句:
insert into Person(persoin_id,first_name,last_name,salary,birth_date,country)
values
(100,'dato','datuashvili',350,to_date('01/01/10','DD/MM/YY'),'georgia') ;
--- as it was here ---^
insert into Person(persoin_id,first_name,last_name,salary,birth_date,country)
values
(101,'irakli','oqruashvili',350,to_date('01/03/10','DD/MM/YY'),'georgia') ;
或使用此方法:
insert into Person(persoin_id,first_name,last_name,salary,birth_date,country)
select
(100,'dato','datuashvili',350,to_date('01/01/10','DD/MM/YY'),'georgia')
from dual
union all select
(101,'irakli','oqruashvili',350,to_date('01/03/10','DD/MM/YY'),'georgia')
from dual
;
答案 1 :(得分:2)
对于2组不同的数据,您需要使用2个insert语句而不是1个...
insert into Person(persoin_id,first_name,last_name,salary,birth_date,country)
values(100,'dato','datuashvili',350,to_date('01/01/10','DD/MM/YY'),'georgia');
insert into Person(persoin_id,first_name,last_name,salary,birth_date,country)
values(101,'irakli','oqruashvili',350,to_date('01/03/10','DD/MM/YY'),'georgia')
答案 2 :(得分:1)
你的结尾有;
:
values(100,'dato','datuashvili',350,to_date('01/01/10','DD/MM/YY'),'georgia');
^
将其更改为,
,并从下一行中删除values
。每个插入只需要一个values
。