当前位置:网站首页>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 .

边栏推荐
- R语言使用car包中的avPlots函数创建变量添加图(Added-variable plots)、在图像交互中,在变量添加图中手动标识(添加)对于每一个预测变量影响较大的强影响点
- 增强 Jupyter Notebook 的功能,这里有四个妙招
- Crawler small operation
- 4 methods for exception handling
- English translation plug-in installation of idea
- Caffeine cache, the king of cache, has stronger performance than guava
- Ingersoll Rand panel maintenance IR Ingersoll Rand microcomputer controller maintenance xe-145m
- 桥接模式(Bridge)
- 组合模式(Composite Pattern)
- 适配器模式(Adapter)
猜你喜欢

JVM family (2) - garbage collection

Au revoir! Navigateur ie, cette route Edge continue pour IE

Ingersoll Rand panel maintenance IR Ingersoll Rand microcomputer controller maintenance xe-145m

Global exception handlers and unified return results

Dotnet uses crossgen2 to readytorun DLL to improve startup performance

Data visualization makes correlation analysis easier to use

通过PyTorch构建的LeNet-5网络对手写数字进行训练和识别

Looking at jBPM from jbm3 to jbm5 and activiti

Dbeaver installation and use tutorial (super detailed installation and use tutorial)

Function sub file writing
随机推荐
老板叫我写个APP自动化--Yaml文件读取--内附整个框架源码
Chapter 3 stack and queue
适配器模式(Adapter)
[happy Lantern Festival] guessing lantern riddles eating lantern festival full of vitality ~ (with lantern riddle guessing games)
Dolphin scheduler uses system time
Starting from full power to accelerate brand renewal, Chang'an electric and electrification products sound the "assembly number"
PyGame game: "Changsha version" millionaire started, dare you ask? (multiple game source codes attached)
Correct conversion between JSON data and list collection
ffmpeg录音录像
解决表单action属性传参时值为null的问题
==And eqauls()
What is the difference between MySQL development environment and test environment??
如何查看谷歌浏览器保存的网页密码
Dbeaver installation and use tutorial (super detailed installation and use tutorial)
增强 Jupyter Notebook 的功能,这里有四个妙招
Wechat applet development log
在OpenCloudOS使用snap安装.NET 6
PMP Exam key summary VI - chart arrangement
Redis sentinel cluster main database failure data recovery ideas # yyds dry goods inventory #
用 Compose 实现个空调,为你的夏日带去清凉