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"