基本SQL命令
库管理
1、查看已有库;show databases;
2、创建库并指定字符集;create database 库名 charset utf8;
3、查看当前所在库; select database();
4、切换库; use 库名
5、查看库中已有表; show tables;
6、删除库;drop database 库名;
7 查看库中数据编码 show create database 库名;
表管理
1、创建表并指定字符集;create table 表名(字段名 数据名...)charset=utf8;
2、查看创建表的语句 (字符集、存储引擎);show create table 表名
3、查看表结构; desc 表名;
4、删除表; drop table 表名
create table tab(id int primary key auto_increment,
name varchar(10),
gender enum('m','w'),
scores float);
表记录管理
1、增 :insert into 表名(字段名) values(),();
2、删 :delete from 表名 where 条件;
3、改 :update 表名 set 字段名=值,字段名=值 where 条件;
4、查 :select 字段名,xxx from 表名 where 条件;
表字段管理(alter table表名)
1、增 :alter table 表名 add 字段名 类型 [first|after];
2、删 :alter table 表名 drop 字段名;
3、改 :alter table 表名 modify 字段名 新类型;
4、表重命名 :alter table 表名 rename 新表名;