您的 SQL 语法有误 [MariaDB]

You have an error in your SQL syntax [MariaDB]

我在使用 MariaDB 开发 javaEE 应用程序时遇到此错误。

错误是:

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 'STARTING DATE, TITLE VARCHAR(255), CREATOR VARCHAR(255), LOCATION BIGINT, FORECA' at line 1

这是有问题的查询:

CREATE TABLE EVENT 
(
   ID VARCHAR(255) NOT NULL, 
   DESCRIPTION VARCHAR(255), 
   ENDING DATE, 
   ISALLDAY TINYINT(1) default 0, 
   PUBLICEVENT TINYINT(1) default 0, 
   STARTING DATE, 
   TITLE VARCHAR(255), 
   CREATOR VARCHAR(255), 
   LOCATION BIGINT, 
   FORECAST BIGINT, 
   PRIMARY KEY (ID);

我不知道是什么问题...

你有两个错别字:

  1. STARTING - 是保留字 - 使用反引号
  2. 你忘了右括号

此脚本应该有效:

CREATE TABLE EVENT 
(
   ID VARCHAR(255) NOT NULL, 
   DESCRIPTION VARCHAR(255), 
   ENDING DATE, 
   ISALLDAY TINYINT(1) default 0, 
   PUBLICEVENT TINYINT(1) default 0, 
   `STARTING` DATE, 
   TITLE VARCHAR(255), 
   CREATOR VARCHAR(255), 
   LOCATION BIGINT, 
   FORECAST BIGINT, 
   PRIMARY KEY (ID)
);