MySQL小知识点(持续更新)

1.查看创建表的SQL语句

show create table table_name \G;

 

2.查看表的字段信息

show full columns from table_name;

获取以下信息
Field :字段名
Type:字段类型
Collation:字符集
Null :是否可以为NULL
Key:索引(PRI,unique,index)
Default:缺省值
Extra:额外(是否 auto_increment)
Privileges:权限
Comment:备注

 

3.如果表、数据库不存在则创建

create table if not exists table_name(...);
create database if not exists database_name;

 

4.如果表、数据库存在则删除

drop table if exists table_name;
drop database if exists database_name;

 

posted @ 2016-02-23 21:11  fosmj  阅读(194)  评论(0编辑  收藏  举报