In general, the life cycle of data in a database includes 3 stages of data insertion and updating, and data deletion. First, users or systems are required to insert data into the table. Then, the use of data, including the retrieval of data and data updates. Finally, if the data already has no use value, the data is deleted. DML is a collection of data manipulation commands that are used in the life cycle of the data.
In DML, insert the data into the table, use Select to retrieve the data, update the data with update, and use the Delete command to implement the deletion of the data.
1. Data Insertion Command
INSERT INTO table_name (COL_NAME) VALUES (value);
INSERT into Test (Id,name) VALUES (1, ' Xiaowang '). into specifies the name of the data table to insert and the attribute column to insert the data into, and the attribute column can be inconsistent with the order of the fields in the table, but values are in the same order as before, and the types of values need to be consistent.
2. Update Data command
Update updates the data in the data table. UPDATE table_name set col_name=value where condition. Where table_name is the name of the specified table, Col_name is the name of the updated column, value is the updated values, and condition is the updated condition.
Update test set name= ' small Zang ' where id=1. You can update the property value of name id=1 in the test table.
3. Delete Data command
The delete command deletes the data in the table. Delete from table_name where condition. Where table_name is the table name, condition is the condition that the row should meet. If there is no where condition, all data in the table is deleted.
Delete from Test where id = 1 To remove row data with ID 1 in the test table. The integrity constraints of the database cannot be destroyed when data is deleted.
4. Retrieving data commands
Select can retrieve information from the database, complete the selection of relationships in relational algebra, projection, connection and other operations.
Select operation: Use the filter criteria to query the required data. SELECT * FROM table_name where
Projection operations: Displays the required attribute columns. Select Col_name from table_name where
Join operation: The connection operation connects two or more tables together to form the final data row.
SQL language Learning-Data manipulation language