什么是 DDL 和 DML?

发布于 2024-08-27 12:24:38 字数 70 浏览 5 评论 0原文

我听说过有关数据库的术语 DDL 和 DML,但我不明白它们是什么。

它们是什么以及它们与 SQL 有何关系?

I have heard the terms DDL and DML in reference to databases, but I don't understand what they are.

What are they and how do they relate to SQL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

唔猫 2024-09-03 12:24:38

SQL 命令可以分为三个子组,DDL、DML和DCL

以下内容改编自这里MySQL 什么是 DDL、DML 和 DCL?

DDL

DDL是数据定义语言的简称,它处理
数据库模式和描述,数据应如何驻留在
数据库。

  • CREATE – 创建数据库及其对象(表、索引、视图、存储过程、函数和触发器)。
  • ALTER – 更改现有数据库的结构。
  • DROP – 从数据库中删除对象。
  • TRUNCATE – 从表中删除所有记录;此外,为记录分配的所有空间都将被删除。
  • COMMENT – 添加注释到数据字典。
  • RENAME – 重命名对象。

DML

DML 是处理数据的数据操作语言的简称
操作,包括最常见的 SQL 语句,例如 SELECT、
INSERT、UPDATE、DELETE等,用于存储、修改、检索、
删除和更新数据库中的数据。

  • SELECT – 从一个或多个表中检索数据。
  • INSERT – 将数据插入表中。
  • UPDATE – 更新表中的现有数据。
  • DELETE – 删除表中的所有记录。
  • MERGE – UPSERT 操作(插入或更新)
  • CALL – 调用 PL/SQL 或 Java 子程序。
  • 解释计划 - 数据访问路径的解释。
  • LOCK TABLE – 并发控制。

DCL

DCL 是数据控制语言的简称,其中包括命令
比如GRANT,主要关注权利、权限等
数据库系统的控制。

  • GRANT – 允许用户访问数据库的权限。
  • REVOKE – 撤销使用 GRANT 命令授予的用户访问权限。

TCL

TCL 是事务控制语言的简称,它处理
数据库内的事务。

  • COMMIT – 提交事务。
  • ROLLBACK – 在发生任何错误时回滚事务。
  • SAVEPOINT – 事务内的一个点,允许将状态回滚到保存点时的状态。
  • SET TRANSACTION – 指定交易的特征。

SQL command can be divided into three subgroups, DDL, DML and DCL

The following is adapted from here MySQL What is DDL, DML and DCL?:

DDL

DDL is short name of Data Definition Language, which deals with
database schemas and descriptions, of how the data should reside in
the database.

  • CREATE – to create database and its objects like (table, index, views, store procedure, function and triggers).
  • ALTER – alters the structure of the existing database.
  • DROP – delete objects from the database.
  • TRUNCATE – remove all records from a table; also, all spaces allocated for the records are removed.
  • COMMENT – add comments to the data dictionary.
  • RENAME – rename an object.

DML

DML is short name of Data Manipulation Language which deals with data
manipulation, and includes most common SQL statements such SELECT,
INSERT, UPDATE, DELETE etc, and it is used to store, modify, retrieve,
delete and update data in database.

  • SELECT – retrieve data from one or more tables.
  • INSERT – insert data into a table.
  • UPDATE – updates existing data within a table.
  • DELETE – delete all records from a table.
  • MERGE – UPSERT operation (insert or update)
  • CALL – call a PL/SQL or Java subprogram.
  • EXPLAIN PLAN – interpretation of the data access path.
  • LOCK TABLE – concurrency control.

DCL

DCL is short name of Data Control Language which includes commands
such as GRANT, and mostly concerned with rights, permissions and other
controls of the database system.

  • GRANT – allow users access privileges to database.
  • REVOKE – withdraw users access privileges given by using the GRANT command.

TCL

TCL is short name of Transaction Control Language which deals with
transaction within a database.

  • COMMIT – commits a transaction.
  • ROLLBACK – rollback a transaction in case of any error occurs.
  • SAVEPOINT – a point inside a transaction that allows rollback state to what it was at the time of the savepoint.
  • SET TRANSACTION – specify characteristics for the transaction.
分分钟 2024-09-03 12:24:38

DDL数据定义语言:它用于定义数据结构

例如,对于 SQL,它将是诸如 create tablealter table 等指令,...

DML数据操作语言:它用于操作数据本身

例如,对于 SQL,它将是诸如 insertupdatedelete 等指令。

DDL is Data Definition Language : it is used to define data structures.

For example, with SQL, it would be instructions such as create table, alter table, ...

DML is Data Manipulation Language : it is used to manipulate data itself.

For example, with SQL, it would be instructions such as insert, update, delete, ...

梦与时光遇 2024-09-03 12:24:38

DDL数据定义语言:用于定义数据的规范符号
数据库架构。
它适用于架构级别。

DDL 命令为:

create、drop、alter、rename

例如:

create table account (
  account_number  char(10),
 balance integer);

DML数据操作语言。它用于访问和操作数据。

DML 命令有:

select,insert,delete,update,call

例如:

update account set balance = 1000 where account_number = 01;

DDL is Data Definition Language : Specification notation for defining the
database schema.
It works on Schema level.

DDL commands are:

create,drop,alter,rename

For example:

create table account (
  account_number  char(10),
 balance integer);

DML is Data Manipulation Language .It is used for accessing and manipulating the data.

DML commands are:

select,insert,delete,update,call

For example :

update account set balance = 1000 where account_number = 01;
旧伤还要旧人安 2024-09-03 12:24:38

输入图像描述这里

DDL,数据定义语言

  • 创建和修改数据库中数据库对象的结构。
  • 这些数据库对象可能具有表、视图、模式、索引...等,

例如:

  • CREATEALTERDROPTRUNCATECOMMIT

DML、数据操作语言

DML语句对表有影响。这就是我们在表中执行的基本操作。

  • 基本的增删改查操作在表中执行。
  • 这些增删改查操作由SELECTINSERTUPDATE等执行。DML

中使用以下命令:

  • INSERT >、更新选择删除等。

enter image description here

DDL, Data Definition Language

  • Create and modify the structure of database object in a database.
  • These database object may have the Table, view, schema, indexes....etc

e.g.:

  • CREATE, ALTER, DROP, TRUNCATE, COMMIT, etc.

DML, Data Manipulation Language

DML statement are affect on table. So that is the basic operations we perform in a table.

  • Basic crud operation are perform in table.
  • These crud operation are perform by the SELECT, INSERT, UPDATE, etc.

Below Commands are used in DML:

  • INSERT, UPDATE, SELECT, DELETE, etc.
无所谓啦 2024-09-03 12:24:38

通俗地说,假设你想盖一座房子,你会做什么。

DDL 即数据定义语言

  1. 从头开始构建
  2. Rennovate它
  3. 销毁旧的并从头开始重新创建它

,即

  1. CREATE
  2. 更改
  3. 删除和删除CREATE
  4. TRUNCATE

DML 即数据操作语言

人们进出你的房子

  1. SELECT< /code>
  2. DELETE
  3. UPDATE

DCL 即数据控制语言

你想控制人们在房子的哪一部分允许访问和访问类型。

  1. 授予权限

In layman terms suppose you want to build a house, what do you do.

DDL i.e Data Definition Language

  1. Build from scratch
  2. Rennovate it
  3. Destroy the older one and recreate it from scratch

that is

  1. CREATE
  2. ALTER
  3. DROP & CREATE
  4. TRUNCATE

DML i.e. Data Manipulation Language

People come/go inside/from your house

  1. SELECT
  2. DELETE
  3. UPDATE

DCL i.e. Data Control Language

You want to control the people what part of the house they are allowed to access and kind of access.

  1. GRANT PERMISSION
葬﹪忆之殇 2024-09-03 12:24:38

DML是数据操作语言的缩写。它用于检索、存储、修改、删除、插入和更新数据库中的数据。

示例:SELECT、UPDATE、INSERT 语句

<小时>

DDL是数据定义语言的缩写。用于创建和修改数据库中数据库对象的结构。

示例:CREATE、ALTER、DROP 语句

请访问此站点以获取更多信息:http://blog.sqlauthority.com/2008/01/15/sql-server-what-is-dml-ddl-dcl-and-tcl -简介和示例/

DML is abbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database.

Examples: SELECT, UPDATE, INSERT statements


DDL is abbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database.

Examples: CREATE, ALTER, DROP statements

Visit this site for more info: http://blog.sqlauthority.com/2008/01/15/sql-server-what-is-dml-ddl-dcl-and-tcl-introduction-and-examples/

月光色 2024-09-03 12:24:38

DDL = 数据定义语言,提供有关数据的结构和其他信息的任何命令

DML = 数据操作语言,只有3种,INSERT、UPDATE、DELETE。 4、如果你会算MSSQL的SELECT * INTO x_tbl from tbl(ANSI SQL:CREATE TABLE x_tbl AS SELECT * FROM tbl

DDL = Data Definition Language, any commands that provides structure and other information about your data

DML = Data Manipulation Language, there's only 3 of them, INSERT, UPDATE, DELETE. 4, if you will count SELECT * INTO x_tbl from tbl of MSSQL (ANSI SQL: CREATE TABLE x_tbl AS SELECT * FROM tbl)

孤凫 2024-09-03 12:24:38

DDL 是数据定义语言:假设您正在定义数据库。
所以我们使用 CREATE、ALTER TRUNCATE 命令。
DML 是在定义之后我们正在操作数据。所以我们使用 SELECT、INSERT、UPDATE、DELETE 命令。

请记住,DDL 命令是自动提交的。您不需要使用 COMMIT 语句。
DML(数据操作语言)命令需要提交/回滚。

DDL is Data Definition Language: Just think you are defining the DB.
So we use CREATE,ALTER TRUNCATE commands.
DML is after defining we are Manipulating the data. So we use SELECT,INSERT, UPDATE, DELETE command.

Remember DDL commands are auto-committed. You don't need to use COMMIT statements.
DML (Data Manipulation Language) commands need to be commited/rolled back.

只想待在家 2024-09-03 12:24:38

DDL代表数据定义语言。 DDL 用于定义表的结构,例如创建表或向表添加列,甚至删除和截断表。
DML 代表数据操作语言。顾名思义,DML 用于操作表的数据。 DML中有一些命令,例如插入和删除。

DDL stands for Data Definition Language. DDL is used for defining structure of the table such as create a table or adding a column to table and even drop and truncate table.
DML stands for Data Manipulation Language. As the name suggest DML used for manipulating the data of table. There are some commands in DML such as insert and delete.

无边思念无边月 2024-09-03 12:24:38

DDL

创建、更改、删​​除(数据库、表、键、索引、视图、函数、存储过程)

DML

插入、删除、更新、截断(表)

DDL

Create,Alter,Drop of (Databases,Tables,Keys,Index,Views,Functions,Stored Procedures)

DML

Insert ,Delete,Update,Truncate of (Tables)

我很OK 2024-09-03 12:24:38

简单来说。

DDL(数据定义语言):将处理数据结构。定义数据结构。

DML(数据操作语言):将处理数据。操纵数据本身

In simple words.

DDL(Data definition language): will work on structure of data. define the data structures.

DML (data manipulation language): will work on data. manipulates the data itself

梦中的蝴蝶 2024-09-03 12:24:38

DDL:更改架构

DML:更改数据

似乎特定于 MySQL 限制(rails 的源代码)

DDL: Change the schema

DML: Change the data

Seems specific to MySQL limitations (rails's source code)

卖梦商人 2024-09-03 12:24:38

对 DML 的不同回应可能会对调查 dbt 的人有所帮助,dbt 是一种广泛使用的用于部署数据的开源工具转变。 (在此处查看更多详细信息。)

dbt 有助于“select”语句,但不能其他 DML 命令。请参阅,例如 “为什么我不能在转换中编写 DML?”

A different response on DML may be helpful for those investigating dbt, a widely used open source tool for deployment of data transformations. (See More detail here.)

dbt facilitates "select" statements but not other DML commands. See, e.g. "Why can't I just write DML in my transformations?"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文