您的位置:首页 > 数据库

常用sql语句总结

2015-04-01 15:16 211 查看
1、create database Student;//创建数据库student

2、Use student;//换到数据库student

3、Show databases;//查看所有的数据库

4、Show database like ‘%t%’;查看满足。。条件的数据库

5、Show create database student;//查看数据库定义

6、Show create table booka;// 查看表定义

7、Create table name();//创建表

8、drop database 名字//删除数据库

9、alter database 数据库名 charset gbk//修改数据库选项

10、create database if not exists 库名//如果不存在则创建

11、drop database if exists 库名//如果存在,则删除

12、est.itcast //test库内itcast表

13、desc 表名//查看表结构

14、rename table原表名 to 新表名//改表名

15、alter table table_name add column 字段定义 [字段位置]//增加字段

给stu表增加一个age字段:alter table stu add column age int;

16在name后增加一个height字段

alter table stu add column height int after name;

17在最开始增加一个字段

alter table stu add column height int first;

18删除字段height

Alter table stu drop column height;

19、修改已有字段

alter table table_name modify column column_name 新的定义!

20、insert into 表名 (字段列表) values (与字段相对的值列表)

21、select 字段列表 from 表名 [where 条件表达式]

22、delete from 表名 where 条件

23 update 表名 set 字段=新值, 字段n=新值n where 条件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: