0

由于 date Date 变量,“考试”表中出现错误 - 我几乎在所有地方(使用 Google)搜索了答案。

Drop table if exists exams;
CREATE TABLE administration2.exams (
date DATE,
censor VARCHAR(45) ,
idstudents VARCHAR(11),
idcourses VARCHAR(11),
grade INT (11),
PRIMARY KEY (date,censor));

insert into exams(date, censor, idstudents, idcourses, grade)
('2013-11-06', 'Ole Pedersen','201210066', 'dDB', 7),

这是问题('2013-11-06') - 它说:

`syntax_error,UNEXPECTED TEXT_STRING,期待 SELECT_SYM。

我该如何解决?

4

2 回答 2

3

您缺少以下values声明:

insert into exams(date, censor, idstudents, idcourses, grade)
    values ('2013-11-06', 'Ole Pedersen','201210066', 'dDB', 7);

如果您去掉括号,您也可以使用 来执行此操作select

insert into exams(date, censor, idstudents, idcourses, grade)
    select '2013-11-06', 'Ole Pedersen','201210066', 'dDB', 7;
于 2013-09-13T12:41:57.383 回答
1

简单又小巧

insert into exams
    select '2013-11-06', 'Ole Pedersen','201210066', 'dDB', 7 from exams

或者

insert into exams
    values ('2013-11-06', 'Ole Pedersen','201210066', 'dDB', 7);
于 2013-09-13T12:49:51.460 回答