DML, DDL, DCL differences and introduction

Source: Internet
Author: User
Tags savepoint table definition

DML (Data Manipulation language):
They are select, UPDATE, INSERT, DELETE, just like its name, these 4 commands are the languages used to manipulate the data in the database
DDL (data definition Language):
DDL is more than DML, the main command has create, alter, DROP, etc., DDL is mainly used in the definition or Change tables (table) of the structure, data types, links between tables and constraints such as initialization work, most of them in the creation of tables using
DCL (Data Control Language):
is the database control function. is a statement that is used to set or change permissions for a database user or role, including (Grant,deny,revoke, etc.) statements. By default, only people such as Sysadmin,dbcreator,db_owner or db_securityadmin have the power to execute the DCL

DML, DDL, DCL differences
http://bbs.pldsec.com/forum.php?mod=viewthread&tid=119&fromuid=113


Detailed Explanation:
First, DDL is Data Definition Language statements. Some Examples: Data definition language for defining and managing the language of all objects in a SQL database
1.create-to create objects in the database
2.alter-alters the structure of the database modified
3.drop-delete objects from the database delete
4.truncate-remove all records from a table, including all spaces allocated for the records is removed
TRUNCATE table [table Name].
The following is a description of the usage and rationale of the TRUNCATE statement in MSSQLServer2000:
The Truncate table name is fast and efficient because:
TRUNCATE table is functionally the same as a DELETE statement without a WHERE clause: Both delete all rows in the table. However, TRUNCATE TABLE is faster than DELETE and uses less system and transaction log resources.
The DELETE statement deletes one row at a time and records an entry in the transaction log for each row that is deleted. TRUNCATE table deletes data by releasing the data page used to store the table data, and records the release of the page only in the transaction log.
TRUNCATE table deletes all rows in the table, but the table structure and its columns, constraints, indexes, and so on, remain unchanged. The count value used for the new row identity is reset to the seed of the column. If you want to preserve the identity count value, use DELETE instead. If you want to delete the table definition and its data, use the DROP table statement.
For tables referenced by the FOREIGN KEY constraint, you cannot use TRUNCATE table and you should use a DELETE statement without a WHERE clause. Because TRUNCATE TABLE is not recorded in the log, it cannot activate the trigger.
TRUNCATE table cannot be used for tables that participate in an indexed view.
5.comment-add comments to the data dictionary notes
6.grant-gives user ' s access privileges to database authorization
7.revoke-withdraw access privileges given with the grant command to reclaim permissions that have been granted


Two, DML is Data Manipulation Language statements. Some Examples: Data manipulation language, operations such as data processing in SQL are collectively known as Data manipulation languages
       1.select-retrieve data from the A database   &N Bsp        Query
       2.insert-insert data into a table     &N bsp;               add
        3. Update-updates existing data within a table    update
       4.delete-deletes all record s from a table, the space for the records remain    Delete
       5.call-call a PL/SQL or J Ava Subprogram
       6.EXPLAIN plan-explain access path to data
       Each SQL statement executed by an Oracle RDBMS must be evaluated by the Oracle Optimizer. So, understanding how the optimizer chooses (search) the path and how the index is used is a great help in optimizing SQL statements. Explain can be used to quickly and easily find out how the query data in a given SQL statement is obtained, that is, the search path (which we commonly call access path). So that we choose the best query mode to achieve maximum optimization effect.
       7.LOCK table-control concurrency lock for concurrency control


Third, DCL is Data Control Language statements. Some Examples: A Data Control language used to grant or reclaim some kind of privilege to access a database, and to control the time and effect of database manipulation transactions, to monitor the database, etc.
1.commit-save work done Submit
2.savepoint-identify a point in a transaction to which you can later roll back SavePoint
3.rollback-restore database to original since the last COMMIT rollback
4.SET transaction-change TRANSACTION options like what rollback segment to use sets the characteristics of the current transaction, which has no effect on subsequent transactions.

SELECT, UPDATE, INSERT, DELETE, command source: http://www.itpub.net/thread-1718224-1-1.html

DML, DDL, DCL differences and introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.