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

View: 10204|Reply: 0

[Source] SQL method of emptying table data

[Copy link]
Posted on 2/9/2015 2:13:22 PM | | |

truncate table tablename
delete from tablename
The biggest problem with the delete method, is when there is a flag field


It is generally recommended to use delete to delete table fields as much as possible, which has the effect of selective deletion, so often delete from tablename where condition
delete and truncate actually have the same function, except that truncate is not followed by a where conditional sentence, its function is to delete all rows (records) in the table
The biggest difference between the two is that delete is written as a log file, while truncate is directly deleted without writing a log, the former can be recovered, while the latter cannot be recovered, the latter is more dangerous, so it is generally not recommended to use truncate, commonly delete




Previous:SQL Server 2000 creates 1024 tables in a loop
Next:Ordinary SQL statements can be executed with exec
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