This article is a mirror article of machine translation, please click here to jump to the original article.

View: 10592|Reply: 1

[Source] SqlServer--delete, truncate, and Drop delete tables

[Copy link]
Posted on 12/17/2018 1:33:47 PM | | |
--delete from table name

--1> Just delete some data in the table, the table structure is still there.

--2>Delete can delete a portion of data with a where clause, e.g. DELETE FROM Student WHERE sAge > 20

--3> Autonumbering does not revert to its initial value.


--truncate table table name

--1>truncate statement cannot be followed by the where condition, cannot be deleted according to the condition, only all data can be deleted.

--2> Auto-numbering reverts to its initial value.

--3> Using truncate to delete all data in a table is much more efficient than delete, because truncate uses the minimum method to record logs.

--4>truncate deletes data without triggering delete trigger.


--drop table table name

--1> Delete the table itself, that is, delete all the data and table structure (columns, constraints, views, keys) in the table.


Auto numbering explained:

1 Automatic numbering will only grow forward, not backward.
2 If there is an error in inserting data, the automatic number will also increase, and the next time it is inserted, the number will be "skipped".
3. Automatic numbering columns cannot be modified manually.






Previous:Senior high school chemistry review Come on, come on
Next:jQuery list only allows one active check
Posted on 12/17/2018 2:28:34 PM |
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com