date日期变量

时间:2013-09-13 12:40:11

标签: mysql sql date

“考试”表格中出现错误,因为日期变量日期 - 我几乎在所有地方(使用谷歌)搜索了答案。

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。

我该如何解决这个问题?

2 个答案:

答案 0 :(得分: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;

答案 1 :(得分:1)

简单和小

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

OR

insert into exams
    values ('2013-11-06', 'Ole Pedersen','201210066', 'dDB', 7);