常用mysql语句总结

来源:互联网 发布:智能手环要下什么软件 编辑:程序博客网 时间:2024/05/16 11:31

show databases 显示所有数据库

use + 库名 使用库

show  tables     显示当前数据库下所有表名称

describe + 表名    显示当前表结构

create  database + 库名     建立库

create  table + 表名 (

列名 + 数据类型 +not null +auto_increment,

...........................,

primary key(id)

)

drop  database + 库名  删除库

drop  table +表名    删除表

select + 列名 +from +表名 where  列名= 想要搜寻的数据 + and+ ;

insert into 表名( 列名 , 列名 ,)values(‘对应列名所要添加的数据’,);

alter + table + 表名 + drop +column + 列名; 删除列

alter + table + 表名 + add + column +列名; 添加列

alter + talbe + 表名+ chang + column + 原列名 +新列名 ; 修改列名

alter + table + 表名 +modify +column + 列名 +新数据类型 +after +新位置 ;修改数据类型或者位置;


0 0