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

边栏推荐
- 手把手教你处理 JS 逆向之 SVG 映射
- 详解final、finally和finalize
- 解决表单action属性传参时值为null的问题
- Linux下安装redis 、Windows下安装redis(超详细图文教程)
- 缓存之王Caffeine Cache,性能比Guava更强
- JVM系列(2)——垃圾回收
- Explain final, finally, and finalize
- Settings of gift giving module and other custom controls in one-to-one video chat system code
- Read PDF Text and write excel operation
- Numpy array: join, flatten, and add dimensions
猜你喜欢

Linux下安装redis 、Windows下安装redis(超详细图文教程)

HDI的盲孔设计,你注意到这个细节了吗?

纵观jBPM从jBPM3到jBPM5以及Activiti

Redis sentinel cluster main database failure data recovery ideas # yyds dry goods inventory #

组合模式(Composite Pattern)

Function sub file writing

PMP考试重点总结五——执行过程组

Huawei OSPF single region

DBeaver安装与使用教程(超详细安装与使用教程)

Xiaomi's payment company was fined 120000 yuan, involving the illegal opening of payment accounts, etc.: Lei Jun is the legal representative, and the products include MIUI wallet app
随机推荐
What is the difference between MySQL development environment and test environment??
JDBC connection database (MySQL) steps
适配器模式(Adapter)
Bron filter Course Research Report
Google开源依赖注入框架-Guice指南
bye! IE browser, this route edge continues to go on for IE
2020-10-27
六月集训(第28天) —— 动态规划
异常处理4种方法
股票开户用中金证券经理发的开户二维码安全吗?知道的给说一下吧
PMP考试重点总结六——图表整理
PMP examination key summary VIII - monitoring process group (2)
标识符的命名规则和规范
Data visualization makes correlation analysis easier to use
R语言使用car包中的avPlots函数创建变量添加图(Added-variable plots)、在图像交互中,在变量添加图中手动标识(添加)对于每一个预测变量影响较大的强影响点
Flip CEP skip policy aftermatchskipstrategy Skippastlastevent() matched no longer matches the Bikeng Guide
理想中的接口自动化项目
结巴分词器_分词器原理
读取pdf图片并识别内容
再见!IE浏览器,这条路由Edge替IE继续走下去