Inserting, updating, deleting tables in the database

Source: Internet
Author: User

The most common operations in a database table are insert, UPDATE, and delete. Here's a look at:

1. Inserting insert

When using a template statement, insert into indicates values.
For example:

Insert has the following points to note:
1) Insert Into-select Inserts the results of the lookup into another table;
2) The data inserted must be the same as the field type in the table, or can be implicitly converted;

2. Updating the update

The update is to update the existing data changes.
Example:

The update has the following points to note:
1) If there is no where to restrict, then the default update all data;
2) Modify the consistency of the operation and database. If several tables have the same field, then after updating a table, verify that the fields in the remaining tables need to be updated. If the update is not updated, it causes the table to be inconsistent. This time the database system introduced the concept of transaction (transaction) to solve this problem.

3. Remove Delete

Use the Delete from-where statement.
Example:

The following are some of the features of delete:
1) Even if all rows have been deleted, the table structure is still there;
2) If there is no WHERE clause, delete deletes all rows;
3) before deleting, it is best to select-where display some, confirm that the display is need to delete, and then execute the DELETE statement;
4) Truncate delete all rows in the table faster than delete. The cost of using truncate is that there is an error that cannot be restored before the change (rollback).

Inserting, updating, deleting tables in the database

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.