SQL Server Pruning

Source: Internet
Author: User

AA (Id,name)

BB (ID. Address)

A change

1 Multi-table change

Change the address of name to Dawu;

Update AA A INNER join BB B on a.id=b.id

Set b.address= ' Dawu '

where a.name= ' name '

2 single Table

Update AA set aa.names= ' where XXX

Second deletion

1 drop

DROP TABLE TableName

drop table AA Deletes the content and definition, freeing up space. In short, the whole table AA is removed. It is not possible to add data in the future unless a new table is added

2 Delete

Delete from TableName where XX conditionally deletes the table's data or the entire sheet data. However, the custom identity column ID is not deleted, stating that delete delete does not free space

Delete from AA removes all data from the AA table.

Delete from AA where id = 1 delete data in AA table with ID equal to 1

3 truncate

TRUNCATE TABLE TableName

Delete the content, free up space, but do not delete the definition. Unlike drop, he simply empties the table data and does not delete the table structure. The Custom identity column ID is deleted, indicating that truncare delete frees up space. The ID will start at 1.

    • The row data cannot be deleted, and the table must be cleared if it is deleted.
    • Truncate is faster than delete and uses less system and transaction log resources.

      The table after the truncate operation is much faster than the table after the delete operation.

      When the table is emptied, the table and table indexes are reset to their initial size, and delete cannot

SQL Server Pruning

Related Article

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.