SQL language Learning-Data manipulation language

Source: Internet
Author: User

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

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.