mysql 常用操作命令
2012-11-07 16:48
387 查看
建库
create database 库名
选择库
use 库名;
显示数据库中的所有表
show tables;
显示数据库中的一个表
show create table 表名;
创建表
create table 表名;
删除表
drop table 表名;
添加列
alter table 表名 add column 列名 not null ;
修改列
alter table 表名 modify column 列名 not null;
添加主键
alter table 表名 add primary key (列名);
删除主键
alter table 表名 drop primary key;
添加索引
alter table 表名 add index 索引名(列名);
删除索引
alter table 表名 drop index 索引名(列名);
添加外键
alter table 表名 add constraint 外键名 foreign key (列名) references 指向的表名 (列名) on delete cascade on update cascade
删除外键
alter table 表名 drop constraint 外键名
alter table 表名 drop foreign key 外键名
修改引擎
alter table 表名 type=InnoDB;
create database 库名
选择库
use 库名;
显示数据库中的所有表
show tables;
显示数据库中的一个表
show create table 表名;
创建表
create table 表名;
删除表
drop table 表名;
添加列
alter table 表名 add column 列名 not null ;
修改列
alter table 表名 modify column 列名 not null;
添加主键
alter table 表名 add primary key (列名);
删除主键
alter table 表名 drop primary key;
添加索引
alter table 表名 add index 索引名(列名);
删除索引
alter table 表名 drop index 索引名(列名);
添加外键
alter table 表名 add constraint 外键名 foreign key (列名) references 指向的表名 (列名) on delete cascade on update cascade
删除外键
alter table 表名 drop constraint 外键名
alter table 表名 drop foreign key 外键名
修改引擎
alter table 表名 type=InnoDB;
相关文章推荐
- mysql 的基本操作以及常用命令
- Linux操作Mysql常用命令
- mysql常用操作命令
- Mysql几个常用操作命令
- Windows平台下MySQL常用操作与命令
- MySql的一些常用命令操作
- MySql 常用操作命令介绍
- mysql常用操作 密码,常用命令,用户管理
- mysql 命令 常用操作
- 学习MySQL常用操作命令详细介绍
- mysql一些常用的操作命令
- mysql 常用操作命令
- CentOS系统操作mysql的常用命令
- MySql:操作数据库以及一些常用的命令
- 常用PHP操作MySQL命令
- MYSQL常用命令(二) 基本操作命令
- Linux mysql常用操作命令
- (转载)MySQL操作常用命令大全
- CentOS系统操作mysql的常用命令
- 数据库常用命令-mysql(一)-登录,数据库操作,表操作