常用sql语句总结

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//修改数据库选项

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

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

12est.itcast  //test库内itcast

13desc 表名//查看表结构

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

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

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

16name后增加一个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 新的定义!

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

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

22delete from 表名 where 条件

23 update 表名 set 字段=新值字段n=新值n where 条件

 

 

 

原文地址:https://www.cnblogs.com/zhaoshunjie/p/4383924.html