Understanding of DDL, DML, and DCL
1、DDL
1-1. Overview of DDL
DDL (Data Definition Language) is used to manipulate objects and object properties, such as objectsdatabaseThe management and definition of DDL's management and definition of these objects and properties is reflected in Create, Drop, and Alter. Special attention: The concept of "object" in DDL operations, "object" includes the object and its attributes, and the object is the smallest and larger than the record. Take a table as an example: Create creates a data table, Alter can change the fields of the table, Drop can delete the table, from here we can see that DDL stands at the height, he will not operate on the specific data.
1-2. Main statements (operations) of DDL
Create statement: You can create a database and some objects of the database.
Drop statement: You can delete data tables, indexes, triggers, conditional constraints, and data table permissions.
Alter statement: Modify the definition and attributes of the data table.
1-3. Operation objects of DDL (table)
1-3-1. The concept of table
The creation of tables is to store data, because the data we store is not accessible, so we need to define some data types to facilitate management.
1-3-2. Attributes of the table
Primary key attributes: The primary key is the primary key constraint, but the name is different, the naming of the primary key is biased towards virtual (that is, the description of the matter), the naming of the primary key constraint is biased towards the actual gain (that is, the implementation of the operation is described), which describes the same thing, and the primary key constraint is an attribute in the table; There can be up to one primary key in a table; A primary key can be defined in one or more fields; The primary key makes the value of one or more fields unique and not null to do so by the value of that field or the value in that group of fields that uniquely represents a record.
Unique attributes: There can only be one primary key attribute in a table, and unique constraints are proposed for square table users. Unique constraints can be defined on one or more fields; The unique constraint makes the value in that field or group of fields unique, which can be empty, however, cannot be repeated.
Foreign key attributes: also called foreign keys, also known as foreign key constraints, the relationship between primary keys and primary key constraints is the same; The foreign key constraint targets two tables, if the primary keyword of table A is a field in table B, the field is called the foreign key of table B, table A is called the master table, and table B is called the slave table, but note that the computer must know that you are in this relationship.
Verification, Null, and Default Attributes: Verification attributes are also called verification constraints, null attributes are also called null constraints, and default attributes are also called default constraints. These names describe a thing, describe a situation, and of course we can do it artificially (just pay attention to the input data), but their original intention is to automate, that is, let the computer do it.
(Do you know why the index is automatically created when the primary key and unique constraints are created?) And it is the only index, think about which fields are mostly used for indexes, and the role of indexes will be known. Operations like primary key constraints, unique constraints, non-null constraints, foreign key constraints, check constraints, and default constraints all give tables certain properties, so here I think they are all properties of the table. )
2、DML
2-1. Overview of DML
DML (Data Manipulation Language) is used to manipulate the data contained in database objects, that is, the unit of operation is records.
2-2. Main statements (operations) of DML
Insert statement: Insert a record into the data sheet.
Delete statement: Deleting one or more records in a data table can also delete all records in the data table, but its operation object is still a record.
Update statement: Used to modify the contents of records in an existing table.
2-3. The operation object of DML - record
2-3-1, attention
When we perform Insert, Delete, and Update operations on records, we must pay attention to some DDL operations on them.
3、DCL
3-1. Overview of DCL
DCL (Data Control Language) operations are the permissions of database objects, and the determination of these operations makes the data more secure.
3-2. Main Statements (Operations) of DCL
Grant statement: Allows the creator of an object to give certain permissions to a user, a group or all users (PUBLIC).
Revoke statement: You can revoke access to a user or a group or all users
3-3. DCL Operator (User)
The user in this case refers to the database user.
|