DQL
select * from t1
DML
update
update t1 set t1.name = '张珊' where t1.id = 20
delete
delete from t1 [Where] -- 自动增长的列的记录值不变,
-- 对于新添加的记录不会重新重1开始计数
使用delete后可通过一下方式回滚数据
insert
insert into t1(id,name)
values(1,'张珊')
DDL
drop
drop database gmall;
drop table if exists user_info;
truncate
truncate table product_sku;-- 自动增长的列的记录值重新归一
create
create database gmall;
create table user_info;
create user 'tzk'@'%' identified by 'tzk'
create table if not exists
alter
-- 修改字段名
alter table user_info change column advice_id adv_id varchar(30)
-- 修改字段类型和约束
alter table user_info modify column adv_id bigint
-- 添加字段
alter table user_info add column address_id bigint
-- 删除字段
alter table user_info drop column address_id
-- 修改表名
alter table user_info rename [to] user_info_t2
DCL
grant
grant select,insert on gmall.* to 'tzk'@'%';
grant all privileges on gmall.* to 'tzk'@'%';
grant all privileges on *.* to 'tzk'@'%' with grant option;
revoke
revoke all privileges on *.* from 'tzk'@'%'