当前位置:网站首页>How to distinguish and define DQL, DML, DDL and DCL in SQL
How to distinguish and define DQL, DML, DDL and DCL in SQL
2022-06-28 10:00:00 【51CTO】
Table of Contents
- DDL: Operating the database 、 surface
- Operating the database :CRUD
- C(Create): establish
- R(Retrieve): Inquire about
- U(Update): modify
- D(Delete): Delete
- Using a database
- Operation table
- DML: Add, delete and modify the data in the table
- DQL: Look up the records in the table
- DCL: Manage users , to grant authorization
- TCL: Transaction control
SQL(Structured Query Language) Structured query language is the core language of database , It's a high-level nonprocedural programming language , It is also the implementation of the classic declarative programming paradigm .
SQL General grammar
- SQL Statements can be written in one or more lines , It ends with a semicolon .
- You can use spaces and indents to enhance the readability of statements .
- MySQL Database SQL Statement is case insensitive , It is recommended to use uppercase .
- notes
- Single-line comments : – The comment or # The comment (mysql specific )
- Multiline comment : / notes /
DDL: Operating the database 、 surface
DDL(Data Definition Language) Data definition language , It mainly operates databases and tables , Database related operations include database creation , Delete Library , Table related operation creation table 、 Delete table 、 Modify table fields 、 Modify constraints and other operations , Keywords generally include :create、drop、alter、truncate、comment,rename.
Operating the database :CRUD
C(Create): establish
R(Retrieve): Inquire about
U(Update): modify
D(Delete): Delete
Using a database
Operation table
C(Create): establish
grammar :
create table Table name (
Name 1 data type 1,
Name 2 data type 2,
…
Name n data type n
);
Be careful : The last column , There is no need to add comma ,
Database type :
- int: Integer types
age int, - double: Decimal type
score double(5,2) - date: date , Include only mm / DD / yyyy ,yyyy-MM-dd
- datetime: date , Including month, day, hour, minute, second yyyy-MM-dd HH:mm:ss
- timestamp: Wrong type of time Including month, day, hour, minute, second yyyy-MM-dd HH:mm:ss
If you don't assign a value to this field in the future , Or assign the value to null, The current system time is used by default , To automatically assign - varchar: character string
name varchar(20): The biggest name 20 Characters
zhangsan 8 Characters Zhang San 2 Characters
Create a table case :
create table student(
id int,
name varchar(32),
age int ,
score double(4,1),
birthday date,
insert_time timestamp
);
Copy table :
create table Table name like The name of the copied table ;
R(Retrieve): Inquire about
Query all table names in a database
show tables;
Query table structure
desc Table name ;
U(Update): modify
D(Delete): Delete
DML: Add, delete and modify the data in the table
DML(Data Manipulation Language) Data operation language , Do some simple operations on the data in the database , There are generally three keywords :insert, delete, update.
DQL: Look up the records in the table
DQL(Data Query Language) Data query language , Data retrieval statements , Used to get data from a table . Usually the most commonly used is reserved words select. The commonly used statement keywords are :SELECT, FROM, WHERE, ORDER BY, HAVING,ASC|DESC etc. .
DCL: Manage users , to grant authorization
DCL(Data Control Language) Data control language , Such as grant to grant authorization 、revoke Revocation of authority, etc , It is mainly used to control access rights or command submission .
Manage users
Add users :
- grammar :CREATE USER ‘ user name ’@‘ Host name ’ IDENTIFIED BY ‘ password ’;
Delete user :
- grammar :DROP USER ‘ user name ’@‘ Host name ’;
Change user password :
- mysql I forgot root User's password ?
1. cmd – > net stop mysql stop it mysql service
- The administrator is required to run the cmd
2. Start with no validation mysql service : mysqld --skip-grant-tables
2. Open up new cmd window , Direct input mysql command , Knock back . You can log in successfully
2. use mysql;
2. update user set password = password(‘ Your new password ’) where user = ‘root’;
2. Close two windows
2. Open Task Manager , Manual end mysqld.exe The process of
2. start-up mysql service
2. Log in with the new password .
Query the user :
Rights management
Query authority :
Grant authority
Revoke authority
TCL: Transaction control
TCL(Transaction Control Language) Transaction control language : Such as commit Commit transaction ,rollback Roll back the transaction set transaction Modify the transaction isolation level of the database or the access mode of the table data in the transaction .
Concept :
If a business operation contains multiple steps , Managed by affairs , So these operations are either successful at the same time , Or fail at the same time .
operation :
This is the end of this article ,
If you have any harvest, you are welcome to like, collect and pay attention to ️, Your encouragement is my biggest motivation .
If you have any wrong questions, you are welcome to point out .
Home page : Share a cup of no blog summaryKeep loving , Go to the next mountain and sea .

边栏推荐
猜你喜欢
随机推荐
SQL中的DQL、DML、DDL和DCL是怎么区分和定义的
手把手教你处理 JS 逆向之 SVG 映射
云服务器MYSQL查询速度慢
Why does istio use spirit for identity authentication?
Key summary IV of PMP examination - planning process group (2)
flink cep 跳过策略 AfterMatchSkipStrategy.skipPastLastEvent() 匹配过的不再匹配 碧坑指南
R language plot visualization: plot to visualize overlapping histograms, and use geom at the bottom edge of the histogram_ The rugfunction adds marginal rugplots
[happy Lantern Festival] guessing lantern riddles eating lantern festival full of vitality ~ (with lantern riddle guessing games)
读取pdf图片并识别内容
R语言使用car包中的avPlots函数创建变量添加图(Added-variable plots)、在图像交互中,在变量添加图中手动标识(添加)对于每一个预测变量影响较大的强影响点
Read PDF image and identify content
PMP考试重点总结七——监控过程组(1)
Install using snap in opencloudos NET 6
浅谈小程序对传媒行业数字化的影响
DolphinScheduler使用系统时间
增强 Jupyter Notebook 的功能,这里有四个妙招
Caffeine cache, the king of cache, has stronger performance than guava
PMP Exam key summary VI - chart arrangement
Flip CEP skip policy aftermatchskipstrategy Skippastlastevent() matched no longer matches the Bikeng Guide
Read PDF Text and write excel operation









