Home >Database >Mysql Tutorial >Master DML, DDL, and DCL in MySQL

Master DML, DDL, and DCL in MySQL

coldplay.xixi
coldplay.xixiforward
2020-11-23 17:43:273719browse

mysql video tutorialThe column introduces the differences between DML, DDL and DCL.

Master DML, DDL, and DCL in MySQL

Introduction

For a long time, many people have been unable to distinguish what the abbreviations of these three things are, what they stand for, and when they encounter them in interviews. It may be too easy to overdo it, so today I will share these three little knowledge points with you!

In fact, these three concepts should be familiar to friends who use CURD every day, it can be said that they are used every day

DML (data manipulation language) Data manipulation language

DML: The select, update, insert, and delete we often use are mainly used to manipulate database data. Some operations, that is, adding, deleting, modifying, and querying data, are called ==DML==

For example, the following SQL code:

SELECT 字段名 | *  FROM 表名称;
UPDATE 表名称 SET 字段名='新值' WHERE 字段名='某值';
INSERT INTO table_name (列1,列2,...) VALUES (值1,值2,...);
DELETE FROM 表名称 WHERE 列名称='某值';

DDL (data definition language) data definition language

DDL: These are some SQL statements we use when creating tables. For example: CREATE, ALTER, DROP, etc. DDL is mainly used for initialization operations such as defining tables or changing the physical structure, data types, links between tables, and physical constraints of tables.

For example, the following SQL code:

#--建表
create table 表名称(
列名称1, 数据类型,
列名称2, 数据类型,
...
)engine=innodb default charset=utf8mb4 collate=utf8mb4_general_ci
#engine=innodb 设置表的引擎
#default charset=utf8mb4  设置表的编码字符集
#collate=utf8mb4_general_ci 设置字符序
#--修改表
alter table 表名称 drop 字段名;
alter table 表名称 add 字段名 数据类型 [字段约束] [字段约束];
#--等等这样的语句...

DCL(Data Control Language)Data Control Language

DCL: used to set or change database user role permissions Statements such as grant and revoke statements

create user 'test_r'@'%' IDENTIFIED BY 'test_rpwd';
GRANT SELECT ON `test_db`.* TO 'test_r'@'%' IDENTIFIED BY 'test_rpwd';

Related free learning recommendations:mysql video tutorial

The above is the detailed content of Master DML, DDL, and DCL in MySQL. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:juejin.im. If there is any infringement, please contact admin@php.cn delete