目录
show databases;
create database if not exists mydb1;
use mydb1;
drop database if exists mydb1;
alter database mydb1 character set utf-8;
create table if not exists 表名(
sid int, name varchar(20),gender varchar(20),
age int, birth date, address varchar(20), score double );
show tables;
show create table 表名;
desc 表名;
drop table 表名;
alter table 表名 add 列名 类型(长度)[约束];
alter table 表名 change 旧列名 新列名 类型(长度)[约束];
alter table 表名 drop 列名;
rename table 表名 to 新表名;
insert into 表名 (列名1,列名2,列名.....)values(值1,值2,值3.....)
update 表名 set 字段名=值,字段名=值...where 条件;
delete from 表名 where 条件;
truncate table 表名 或者 truncate 表名;
注意:delete和truncate原理不同,delete只删除内容,而truncate类似于drop table,可以理解为是将整个表删除,然后再创建表