这个MySQL命令有什么问题?

时间:2014-04-24 11:49:40

标签: mysql

有人可以告诉我出了什么问题吗?

CREATE TABLE IF NOT EXISTS ifm.LinksTable (
  file_system_id SMALLINT NOT NULL ,
  inode_number BIGINT AUTO_INCREMENT  ,
  parent_inode_number BIG INT  ,
  virtual_name VARCHAR(256)  , 
  UNIQUE INDEX (parent_inode_number, virtual_name, file_system_id),
  inode_type CHAR(1) ,
  symbolic_link_inode BIGINT DEFAULT 0 ,
  current_version_number SMALLINT DEFAULT 0 ,
  number_of_links_to_file SMALLINT DEFAULT 0 ,
  PATH  varchar(1000),
  dir_level  INT ,
  time_last_modified INT ,
  time_last_accessed INT ,
  time_last_changed INT ,
  created_date INT ,
  permissions INT ,
  uid INT ,
  gid INT ,
  deleted_flag CHAR(1) , 
  PRIMARY KEY(file_system_id, inode_number)
);

错误是:

  

错误1064(42000):您的SQL语法有错误;检查   手册,对应右边的MySQL服务器版本   在'BIG INT,virtual_name VARCHAR(256),UNIQUE附近使用的语法   INDEX(parent_inode_number,virtua'在第1行

请注意我是MySQL命令的新手,但要理解SQL。

这是MySQL def文件的样子,我添加了a和path

cat ifmLinksTable.mysqldef
file_system_id,smallint not null
inode_number,bigint auto_increment
parent_inode_number,bigint
virtual_name,varchar(256) , unique index (parent_inode_number, virtual_name, file_system_id)
inode_type,char(1)
symbolic_link_inode,bigint default 0
current_version_number,smallint default 0
number_of_links_to_file,smallint default 0
time_last_modified,int
time_last_accessed,int
time_last_changed,int
created_date,int
permissions,int
uid,int
gid,int
deleted_flag,char(1), primary key(file_system_id, inode_number)

2 个答案:

答案 0 :(得分:0)

它应该是BIGINT,没有空格,但不是BIG INT

CREATE TABLE IF NOT EXISTS ifm.LinksTable (
  file_system_id SMALLINT NOT NULL ,
  inode_number BIGINT AUTO_INCREMENT  ,
  parent_inode_number BIGINT  ,
  virtual_name VARCHAR(256)  , 
  UNIQUE INDEX (parent_inode_number, virtual_name, file_system_id),
  inode_type CHAR(1) ,
  symbolic_link_inode BIGINT DEFAULT 0 ,
  current_version_number SMALLINT DEFAULT 0 ,
  number_of_links_to_file SMALLINT DEFAULT 0 ,
  PATH  varchar(1000),
  dir_level  INT ,
  time_last_modified INT ,
  time_last_accessed INT ,
  time_last_changed INT ,
  created_date INT ,
  permissions INT ,
  uid INT ,
  gid INT ,
  deleted_flag CHAR(1) , 
  PRIMARY KEY(file_system_id, inode_number)
);

答案 1 :(得分:0)

我看到一些错误:parent_inode_number BIG INT => parent_inode_number BIGINT(只是一些错字^^),另一个是VARCHAR:VARCHAR最大值是255所以VARCHAR(256)和VARCHAR(1000)是不可能的

希望我能帮忙!