您好,欢迎访问一九零五行业门户网

MySQL数据库常用命令总结_MySQL

mysql数据库常用命令总结 1.先判断数据库/表是否存在,再建立数据库/表 create database if not exists database_name;create table if not exists table_name;
2.mysql修改表名,mysql修改表的名称 aiter table table_old_name rename [to] table_new_name; rename table table_old_name to table_new_name;
3.mysql添加列,mysql增加列
alter table table_name add column_name data_type not null default xxx [after/before] column_name;alter table person add age tinyint not null default 16 after name;
4.mysql删除列
alter table table_name drop [column] column_name;alter table person drop column age;
5.mysql修改列
alter table table_name change [column] column_old_name column_new_name 列声明
6.mysql修改列的数据类型,仅仅修改列的数据类型
alter table table_name modify [column] column_name data_type;alter table person modify column age int not null default 16;
7.mysql建立索引
alter table table_name add index/unique/fulltext [索引名](列名); 不加索引名,则直接以列名命名 alter table table_name add primary key (列名);
8.mysql删除索引
alter table table_name drop index 索引名; alter table table_name drop primary key;
9.mysql查看所有的索引
show index from table_name; show index from table_name/g;
10.mysql中/g的作用 mysql语句中使用/g参数改变输出结果集的显示方式
其它类似信息

推荐信息