[英]MySql tables, creating new
it seems like my syntax for the following command is incorrect.我的以下命令的语法似乎不正确。 The error message points to the default current timestamp.
错误消息指向默认的当前时间戳。 Can someone point out where am I going wrong?
有人可以指出我哪里出错了吗? Your help is much appreciated as I'm working on my first app.
非常感谢您的帮助,因为我正在开发我的第一个应用程序。 My code is the following:
我的代码如下:
CREATE TABLE ingredients (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
ingredient VARCHAR(100),
created_at DEFAULT CURRENT_TIMESTAMP,
updated_at DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
You forgot the Data Type ;)您忘记了数据类型;)
The correct Query is following:正确的查询如下:
CREATE TABLE ingredients (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
ingredient VARCHAR(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
Check out the docs: MySQL Docs |查看文档: MySQL 文档 | Create Table
创建表
You can check your syntax with following tool: SQL Validator您可以使用以下工具检查语法: SQL Validator
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.