SQL Server: "delete" and "remove"

Source: Internet
Author: User

1. Preface 2. Delete through SSMs 3. Delete by SQL statement
    • 3.1 Deleting a single row of data
    • 3.2 Delete all row data
    • 3.3 Deleting tables and databases
1. Preface

Additions and deletions are the operation of the data, where "delete" the corresponding SQL statement is "delete", that is, "delete" meaning.
This article mainly introduces the deletion of data, respectively, using Ssms/sql to delete the data.

2. Delete via SSMs

2.1 Select Database->ssmstest-> table->dbo.student Right-click dbo.student Select Edit First 200 rows. Right-click to select Delete, which row you want to remove.

2.2 Select the database->ssmstest-> table, right-click Delete the entire table directly, even with the data is deleted. Note that there are no foreign key constraints on the table, but you cannot delete the primary table. To delete the main table, delete the sub-table first.

3. Delete by SQL statement3.1 Deleting a single row of data

The syntax for SQL statement Delete is as follows:

DELETE FROM 表名称 WHERE 列名称 = 值

For example:

delete from student where sno = ‘0001‘
3.2 Delete all row data

You can delete all rows without deleting the table. This means that the structure, properties, and indexes of the table are complete:

DELETE FROM table_name

Or

DELETE * FROM table_name
3.3 Deleting tables and databases

3.3.1 using the DROP Index command to delete an index in a table

DROP INDEX table_name.index_name

3.3.2 Use the DROP TABLE statement to delete tables (the structure, properties, and indexes of the table are also deleted):

DROP TABLE 表名称

3.3.3 Use the DROP DATABASE statement to delete the databases:

DROP DATABASE 数据库名称

3.3.4 If we just need to get rid of the data in the table, but not the table itself, then we should use the TRUNCATE TABLE command (just delete the data in the table):

TRUNCATE TABLE 表名称

SQL Server: "delete" and "remove"

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.