首页 > 数据库技术 > 详细

mysql 相关知识

时间:2019-04-15 21:42:13      阅读:143      评论:0      收藏:0      [点我收藏+]

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>;

mysql 相关知识

原文:https://www.cnblogs.com/lgh-520/p/10713118.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!