$sql1= "CREATE TABLE bookapp(
id int NOT NULL AUTO_INCREMENT,
name VARCHAR(30),
pnumber int(11),
emailID VARCHAR(50),
reg_date datetime()
PRIMARY KEY(id)
)";
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''', NULL)' at line 1
最佳答案
您可以使用以下内容创建表:
CREATE TABLE bookapp(
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30),
pnumber INT(11),
emailID VARCHAR(50),
reg_date DATETIME,
PRIMARY KEY(id)
);
解释:
(
and)
无效。DATETIME
不需要长度。- 您必须使用
,
分隔列定义。您在reg_date
列之后忘记了它。
DATETIME
上的 提示(对您的错误消息):
您给定的 CREATE TABLE
抛出另一条错误消息,这与您的不同:
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') PRIMARY KEY(id) )' at line 6
关于引用 Null 的 mysql 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41746459/