CREATE TABLE "USERMASTER"
(
"REGISTRATION_ID" VARCHAR2(10) NOT NULL ENABLE,
"USERNAME" VARCHAR2(10) NOT NULL ENABLE,
"PASSWORD" VARCHAR2(10) NOT NULL ENABLE,
"TYPE" VARCHAR2(7) NOT NULL ENABLE,
"NAME" VARCHAR2(25) NOT NULL ENABLE,
CONSTRAINT "USERMASTER_PK" PRIMARY KEY ("REGISTRATION_ID") ENABLE
)
我在mysql 5.1上执行时遇到错误。请给我解决方案。
答案 0 :(得分:0)
如Schema Object Names所述,MySQL标识符引号字符是反引号,而不是双引号(除非启用了ANSI_QUOTES
SQL模式):
标识符引号字符是反引号(“
`
”):mysql> SELECT * FROM `select` WHERE `select`.id > 100;
如果启用了
ANSI_QUOTES
SQL模式,也允许在双引号内引用标识符:
mysql> CREATE TABLE "test" (col INT); ERROR 1064: You have an error in your SQL syntax... mysql> SET sql_mode='ANSI_QUOTES'; mysql> CREATE TABLE "test" (col INT); Query OK, 0 rows affected (0.00 sec)
如String Types所述,MySQL没有VARCHAR2
数据类型:
如CREATE TABLE
Syntax所述,MySQL无法识别ENABLE
字段修饰符:
column_definition: data_type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT] [UNIQUE [KEY] | [PRIMARY] KEY] [COMMENT 'string'] [COLUMN_FORMAT {FIXED|DYNAMIC|DEFAULT}] [STORAGE {DISK|MEMORY|DEFAULT}] [reference_definition]
因此,MySQL中的等效语法是:
CREATE TABLE `USERMASTER`
(
`REGISTRATION_ID` VARCHAR(10) NOT NULL,
`USERNAME` VARCHAR(10) NOT NULL,
`PASSWORD` VARCHAR(10) NOT NULL,
`TYPE` VARCHAR(7) NOT NULL,
`NAME` VARCHAR(25) NOT NULL,
CONSTRAINT `USERMASTER_PK` PRIMARY KEY (`REGISTRATION_ID`)
)