mysql 相关知识

1.显示book数据库下所有表;

show tables from book;

2.查看数据库表内容

2.1  show columns from table_name; 

       show full columns from table_name;

2.2  desc table_name;

3.查看数据库表结构

show create table table_name;

==================================================

创建表

create table table_name(<字段名> <数据类型> <约束条件>,

           <字段名> <数据类型> <约束条件>,

           <字段名> <数据类型> 

);

删除表

drop table table_name if exists table_1,table_2,table_3;

 

修改数据库表

1.添加列

alter table table_name add <新列名><数据类型>[约束条件][filrst]|[after] [已有的列名];

2.修改列名

alter table table_name change<旧列名><新列名><新数据类型>;

===================================================

3.修改列的数据类型

alter table table_name <表名>modify<列名><数据类型>;

4.修改列的排序

alter table table_name modify <列1><数据类型>first|after <列2>

===================================================

5.删除列

alter table <表名> drop <列名>

6.修改表名

alter table table_name_old rename to <table_name_new>;

7.删除有条件的数据

delete from table_name where <condition>;

posted @ 2019-04-15 21:01  奔跑的蜗Liu  阅读(110)  评论(0编辑  收藏  举报