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

边栏推荐
- JVM系列(2)——垃圾回收
- dotnet 使用 Crossgen2 对 DLL 进行 ReadyToRun 提升启动性能
- Read PDF image and identify content
- PHP curl forged IP address and header information code instance - Alibaba cloud
- 2020-10-27
- PMP Exam key summary VI - chart arrangement
- 异常
- Naming rules and specifications for identifiers
- 手机号、邮箱正则验证[通俗易懂]
- Function sub file writing
猜你喜欢

Decorator

Unity AssetBundle asset packaging and asset loading

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

学习机器学习的最佳路径是什么

错过金三银四,找工作4个月,面试15家,终于拿到3个offer,定级P7+

Unity AssetBundle资源打包与资源加载

Explain final, finally, and finalize

An error is reported when uninstalling Oracle

Caffeine cache, the king of cache, has stronger performance than guava

Installing redis under Linux and windows (ultra detailed graphic tutorial)
随机推荐
多线程-并发并行-线程进程
Matplotlib属性及注解
HDI的盲孔设计,你注意到这个细节了吗?
PMP examination key summary VIII - monitoring process group (2)
Au revoir! Navigateur ie, cette route Edge continue pour IE
Abnormal occurrence and solution
详解final、finally和finalize
PyGame game: "Changsha version" millionaire started, dare you ask? (multiple game source codes attached)
学习机器学习的最佳路径是什么
File operations in QT
生成token
Why does istio use spirit for identity authentication?
结巴分词器_分词器原理
Sword finger offer | Fibonacci sequence
2020-10-27
第五章 树和二叉树
异常处理4种方法
PMP Exam key summary IX - closing
==和eqauls()的区别
flink cep 跳过策略 AfterMatchSkipStrategy.skipPastLastEvent() 匹配过的不再匹配 碧坑指南