最近更新:2018-8-31 11:06

本篇文章介绍SQL的常用语法


创建表

1
2
3
4
5
6
create table `a` (
`id` bigint(20) not null AUTO_INCREMENT COMMENT '主键,自增id',
`name` int(4) not null default '0' COMMENT '名称',
primary key (`id`),
unique key `unique_key` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=0 default CHARSET=utf8 COMMENT='一张表';

删除表

1
drop table a

重命名表

1
alter table oldname rename to newname