MySQL常用DDL、DML、DCL、MDL语言整理

最近在刷MySQL课程,贴一下MySQL的常用名词缩写。
整理来源于百度。

一、DDL

  • Data Definition Language 数据库定义语言; 如create procedure之类
创建数据库
CREATE DATABASE [IF NOT EXISTS] DBNAME [CHARACTER SET 'CHAR_NAME'] [COLLATE 'COLL_NAME']
修改:ALTER 删除:DROP(略)

二、DML

  • Data Manipulation Language 数据操纵语言,如insert,delete,update,select(插入、删除、修改、检索)插入修改数据。
#插入
INSERT INTO students (Name,Gender,teacher) VALUE ('dalizi','M','mage'),('wusong','M','zhuima');

INSERT INTO students SET Name='dalizi',Gender='M',tearcher='zhuima';

#更新
UPDATE tb_name SET column=value WHERE column=value;

UPDATE students SET Course='mysql' WHERE Name='dalizi';

#替换
mysql>REPLACE tb_name SET column=value WHERE column=value;

mysql>REPLACE students SET Course='mysql' WHERE Name='dalizi';

#查询
SELECT [DISTINCT] column FROM tb_name WHERE CONDITION;

#创建视图
CREATE VIEW VIEW_NAME AS SELECT....

三、DCL

  • Data Control Language 数据库控制语言,如grant,deny,revoke等,只有管理员才有这样的权限。

创建用户

mysql>CREATE USER 'USERNAME'@'HOST' IDENTIFIED BY 'PASSWORD'

删除用户

mysql>DROP USER 'USERNAME'@'HOSHOST支持通配符

_:任意单个字符

%:任意多个字符

授权

mysql>GRANT pri1,pri2...ON DB_NAME.TB_NAME TO 'USERNAME'@'HOST' [IDENTIFIED BY 'PASSWORD']

取消授权

mysql>REVOKE pri1,pri2...ON DB_NAME.TB_NAME FROM 'USERNAME'@'HOST';

查看授权

mysql>SHOW GRANTS FOR 'USERNAME'@'HOST';

举例:

CREATE USER 'dalizi'@'%' IDENTIFIED BY '123456';

SHOW GRANTS FOR 'dalizi'@'%';

GRANT ALL PRIVILEGES ON testdb.* TO 'dalizi'@'%';

四、MDL

  • Metadata lock,元数据锁,MySQL为实现并发情况下的数据一致性引入的锁机制。

你可能感兴趣的:(MySQL)