首页 > 数据库技术 > 详细

常用sql语句总结

时间:2015-04-01 17:13:14      阅读:293      评论:0      收藏:0      [点我收藏+]

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 条件

 

 

 

常用sql语句总结

原文:http://www.cnblogs.com/zhaoshunjie/p/4383924.html

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