增:1.INSERT INTO 表名(列名1,列名2,...)VALUE(值1,值2,...),(值1,值2,...);
例:insert into Mydatebase()
2.INSERT INTO 表名 SET 列名1=值1,列名2=值2,列名3=值3
ps:1)列数与值个数相等
2)列数与值的类型相等或兼容
CREATE DATABASE Mydatebase;
use Mydatebase;
CREATE TABLE fate
(id INT(5),sex VARCHAR(6),age INT(7));
删:1)Drop +需要删除的内容
例:Drop table fate
2)ALTER TABLE 表名 DROP COLUMN 表名 删除某列
3)truncate 清空数据
改:1)库名的修改:rename 库名 to 库名 将新改旧
2)alter table fate rename to cake 改表格名
alter table an modify column to age int 改类型
alter table an change column to id 123 int 改 列
update an set id=2, sex="男" where age=15
查:1)SELECT version();#查看当前版本信息。
SHOW databases;#输出当前所有的数据库;
SHOW tables; #输出当前数据库smile中所有的表
SHOW tables FROM smile; #输出指定库smile的所有表
SELECT * FROM an; #输出该表an中所有的数据
SELECT idd,sex,age FROM an; #输出该表an中的指定列中的数据;
DESC an 列的状态
2)条件查询 :语句 where 条件
3)联合查询: 语句一 union 语句二
ps:需列数相同,类型相同,顺序相同,默认去重