卡在 SQL 语法错误
Stuck on a SQL Syntax error
我的 SQL 模型有点卡住了。我使用 MySQL Workbench 以图形方式创建模型,并且我创建了一个我认为适合我的用例的模式。但是我无法与数据库同步,因为它给了我以下错误。也许其他人可以看到我做错了什么。显然我目前是盲人...
Executing SQL script in server ERROR: Error 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 'NULL DEFAULT
CURRENT_TIMESTAMP,
last_activity
DATETIME NULL DEFAULT NULL,
' at line 6
SQL Code:
CREATE TABLE IF NOT EXISTS `topas`.`user` (
`id` INT(255) NOT NULL AUTO_INCREMENT,
`username` VARCHAR(50) NOT NULL,
`email` VARCHAR(80) NULL DEFAULT NULL,
`password` VARCHAR(250) NOT NULL,
`created_at` NULL DEFAULT CURRENT_TIMESTAMP,
`last_activity` DATETIME NULL DEFAULT NULL,
UNIQUE INDEX `username_UNIQUE` (`username` ASC),
UNIQUE INDEX `email_UNIQUE` (`email` ASC),
UNIQUE INDEX `id_UNIQUE` (`id` ASC),
PRIMARY KEY (`id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
SQL script execution finished: statements: 3 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
谢谢。
这一行:
`created_at` NULL DEFAULT CURRENT_TIMESTAMP,
缺少类型定义。应该是:
`created_at` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
此行缺少数据类型
`created_at` NULL DEFAULT CURRENT_TIMESTAMP,
您需要将其设置为 TIMESTAMP
或 DATETIME
:
`created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
`created_at` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
您缺少 created_at
列的列类型。
应该是:
`created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
我的 SQL 模型有点卡住了。我使用 MySQL Workbench 以图形方式创建模型,并且我创建了一个我认为适合我的用例的模式。但是我无法与数据库同步,因为它给了我以下错误。也许其他人可以看到我做错了什么。显然我目前是盲人...
Executing SQL script in server ERROR: Error 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 'NULL DEFAULT CURRENT_TIMESTAMP,
last_activity
DATETIME NULL DEFAULT NULL, ' at line 6
SQL Code:
CREATE TABLE IF NOT EXISTS `topas`.`user` (
`id` INT(255) NOT NULL AUTO_INCREMENT,
`username` VARCHAR(50) NOT NULL,
`email` VARCHAR(80) NULL DEFAULT NULL,
`password` VARCHAR(250) NOT NULL,
`created_at` NULL DEFAULT CURRENT_TIMESTAMP,
`last_activity` DATETIME NULL DEFAULT NULL,
UNIQUE INDEX `username_UNIQUE` (`username` ASC),
UNIQUE INDEX `email_UNIQUE` (`email` ASC),
UNIQUE INDEX `id_UNIQUE` (`id` ASC),
PRIMARY KEY (`id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
SQL script execution finished: statements: 3 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
谢谢。
这一行:
`created_at` NULL DEFAULT CURRENT_TIMESTAMP,
缺少类型定义。应该是:
`created_at` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
此行缺少数据类型
`created_at` NULL DEFAULT CURRENT_TIMESTAMP,
您需要将其设置为 TIMESTAMP
或 DATETIME
:
`created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
`created_at` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
您缺少 created_at
列的列类型。
应该是:
`created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,