SQL语句基本命令总结
创建数据库:create database 数据库名称;
删除数据库:drop database 数据库名称;
使用数据库:use 数据库名称;
查看数据库:show databases;
创建表:create table 表名称(字段名1 类型,字段名2 类型……);
删除表:drop table 表名称;
改表名:alter table 表名称 rename to 新表名;
查看表结构:desc 表名;
添加字段:alter table 表名称 add 字段名 类型;
删除字段:alter table 表名称 drop 字段名;
修改字段:alter table 表名称 change 旧的字段名 新的字段名 新的类型;
添加数据:insert into 表名称 (字段名1,字段名2……) values (值1,值2……);
删除数据:delete from 表名称 where 字段名=值;
查看数据:select 字段名 from 表名;select * from 表名;
降序查看数据:select * from 表名 order by 字段名 desc;
升序查看数据:select * from 表名 order by 字段名 asc;
更改数据:update 表名称 set 字段名=新值where 字段名=旧值
选出不同值:select distinct 字段名 from 表名