尝试创建表时出现错误1064(Error 1064 when trying to create a table)
这是代码:
create table `team`.`User`(
`UserID` bigint NOT NULL AUTO_INCREMENT ,
`Username` text(30) NOT NULL ,
`Email` text(30) NOT NULL ,
PRIMARY KEY (`UserID`)
) Engine= [default] comment='' row_format=Default
并且错误消息:
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
'[default] comment='' row_format=Default' at line 6
有人能告诉我为什么我会收到此错误以及如何修复它?
编辑:此代码由SQLyog自动生成。 似乎引擎位导致了问题。 有谁知道如何使用SQLyog设置默认引擎?
Here is the code:
create table `team`.`User`(
`UserID` bigint NOT NULL AUTO_INCREMENT ,
`Username` text(30) NOT NULL ,
`Email` text(30) NOT NULL ,
PRIMARY KEY (`UserID`)
) Engine= [default] comment='' row_format=Default
And the error message:
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
'[default] comment='' row_format=Default' at line 6
Can someone tell me why I'm getting this error and how to fix it?
EDIT: This code was automatically generated by SQLyog. It seems that the Engine bit is causing the problem. Does anyone know how to use SQLyog to set the default engine?
原文:https://stackoverflow.com/questions/11341703
更新时间:2020-10-01 20:10
最满意答案
据我所知,方括号在MySQL中没有任何特殊含义。 你可能与其他一些DBMS混淆了。
ENGINE关键字的有效语法是ENGINE [=] engine_name 。 例如:
ENGINE=InnoDB
... 要么
ENGINE InnoDB
如果您不关心存储引擎,请删除该子句,MySQL将使用默认值。
As far as I know, square brackets don't have any special meaning in MySQL. You're probably confused with some other DBMS.
Valid syntax for the ENGINE keyword is ENGINE [=] engine_name. E.g.:
ENGINE=InnoDB
... or
ENGINE InnoDB
If you don't care about the storage engine, remove the clause and MySQL will use the default.
2012-07-05
相关问答
你在moddate之后错过了一个逗号,并且不确定你是否需要ADD ..... ...
elevation INT(15) NULL,
gtopo30 INT(15),
timezone VARCHAR(40),
moddate DATE,
INDEX (latitude),
INDEX (longitude),
INDEX (fclass)
或者,您可以在创建表后在单独的语句中创建索引,这可能会更容易。 CREATE INDEX id_latitude ON allCountries(l
...
每次声明后都缺少逗号: CREATE TABLE Party_Library
(
Party INT(11),
Library varchar(40),
PRIMARY KEY (Library,Party),
FOREIGN KEY (Party) REFERENCES Party(PartyKey) ON DELETE CASCADE,
FOREIGN KEY (Library) REFERENCES MusicLibraries(MusicSource
...
在上一个列定义之后删除逗号: CREATE TABLE Users(
Usrid INT unsigned auto_increment PRIMARY KEY not null,
Username varchar(20),
Name varchar(25),
Surname varchar(25),
Email varchar(50),
Password varchar(50),
);
它应该是 CREATE TABLE Users(
Usrid
...
您应该从最后一个条目中删除逗号: CREATE TABLE users
(
`a` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
`b` VARCHAR(50) DEFAULT "USER",
`c` INT(1) NOT NULL DEFAULT "0",
`d` VARCHAR(30) NOT NULL,
`e` VARCHAR(30) NOT NULL,
`f` TEXT(30) NOT NULL,
...
你刚刚错过了性别专栏。 CREATE TABLE clan(
first_name VARCHAR(30) NOT NULL,
last_name VARCHAR(30) NOT NULL,
city VARCHAR(30) NOT NULL,
country VARCHAR(30) NOT NULL,
zip MEDIUMINT UNSIGNED NOT NULL,
birth_date DATE NOT NULL ,
sex ENUM("M", "F") NOT NULL,
clan_belo
...
使用圆括号对() 。 不是卷曲的{} 。 还要确保已创建具有完全相同类型的id列的user表。 Use round parenthesis pair (). NOT the curly ones {}. Also make sure you have created user table with an id column with exact same type first.
您的create table语句看起来很好,但是之后没有添加分号: create database isathub
所以它没有执行该语句,并认为create table语句是create database语句的一部分。 Your create table statement looks fine, but you didn't put a semicolon after: create database isathub
So it didn't execute that statement,
...
这是MySQL存储过程的无效语法。 您发布的代码看起来更像Microsoft SQL Server(Transact SQL)语法。 一些观察: MySQL过程变量不能以@开头。 (该字符保留给用户定义的变量。) MySQL不使用NVARCHAR类型。 我相信这是session中character_set_client变量的设置(在创建过程时)是控制过程变量的字符集的东西。 在CREATE PROCEDURE看起来完全select * from parent_user,之前,行select * f
...
据我所知,方括号在MySQL中没有任何特殊含义。 你可能与其他一些DBMS混淆了。 ENGINE关键字的有效语法是ENGINE [=] engine_name 。 例如: ENGINE=InnoDB
... 要么 ENGINE InnoDB
如果您不关心存储引擎,请删除该子句,MySQL将使用默认值。 As far as I know, square brackets don't have any special meaning in MySQL. You're probably confus
...
你混淆了oracle和MySQL。 MySQL不提供VARCHAR2而不提供NUMBER 。 另请参阅此页面以了解Oracle和MySQL中的数据类型差异 。 CREATE TABLE DW.BOOKS(
BIO VARCHAR(250) NOT NULL ,
ID INT(10) NOT NULL ,
REVENUE VARCHAR(20) ,
PRIMARY KEY (ID)
);
You are confusing oracle and
...