数据库在创建数据表的时候经常会报错:
ERROR 1064 (42000): You have an error in your SQL syntax
出现这种情况的原因可能是:
1、拼写错误
2、符合错误,例如()而不是{} 英文和中文符号;;的区别
3、使用了关键字
create table ustomers(id int(11) not null primary key aotu_increment, name varchar(20) null, age int not null);
另外常用的修改表的sql语句小结1
修改表名
alter table <旧表名> rename [to] <行表名>;
修改字段的数据类型
alter table <表名> modify <字段名> <数据类型>;
修改字段名
alter table <表名> change <旧字段名><新字段名><新数据类型>;
添加字段
alter table <表名> add <新字段名><新数据类型>[约束条件][first | after 已存在的字段名];
删除字段
alter table <表名>drop<字段名>;
修改字段的排列位置
alter table <表名> modify <字段1> <数据类型> first |after <字段2>;
修改表的存储引擎
alter table <表名> engine=<更改后的存储引擎名>;
删除表的外健约束
alter table <表名> drop foreign key <外健约束名>
“首先创建外健 constraint 外健约束名 foreign key (本表字段) references 外表名(字段)或者alter table table_name add constraint fk_column_id foreign key(column) references 主键表(column_id)”
删除数据表
drop table [if exists] 表1,表2....alter