In the SQL statement ---- delete table data drop, truncate, and delete usage, droptruncate
Reprinted from: http://www.cnblogs.com/1312mn/p/4422396.html
I. SQL syntax
1. drop table name eg: drop table dbo. Sys_Test2. truncate table name eg:
The difference between delete and truncate: delete generates rollback. If you delete a table with a large amount of data, it will take up a lot of rollback segments. truncate is a DDL operation and does not generate rollback, which is faster.
Oracle Clearing table SQL statement and difference between
Access is similar to the truncate statement in SQL Server.1. Table Name: mytable auto-increment column: myid2. Delete from mytable; (delete data first)3. alter table mytable alter column myid counter (); (corrected auto-incrementing column)When executing this sentence, the system prompts: The field data type is invalid. It is strange that I deleted the table, re-
Define a self-increment column, use Delete, and then insert the data, the self-increment column is still incremented by the maximum value before deletion; If you use truncate and then insert the data, the self-increment column increments from the beginningScript one (using delete):CREATE table #test (codes int identity,valuess int)Insert into #test (valuess) Select 1SELECT * FROM #test----------------Delete from #test------------------Insert into #tes
First,syntax in SQL1. Thedrop table name Eg:drop table dbo. Sys_test2.truncate table name eg:truncate table dbo. Sys_test3.Delete from table name where column name = value Eg:delete from dbo. Sys_test where test= ' Test 'Second,drop,truncate,delete difference1, Drop (delete table): Delete content and definition, free space. Simply put the whole table out . It is not possible to add data in the future unless
of execution was unpleasant. You can also return the number of records that were deleted. Truncate TABLE cannot delete the specified record, and the deleted record cannot be returned. But it executes very fast.Unlike standard SQL statements, the MySQL DELETE statement supports both the order BY and the limit clauses, and with these two clauses, we have more cont
When the data in the table is not needed, you should delete the data and release the space occupied, and the data in the table can be deleted using the DELETE statement or the TRUNCATE statement, described separately below.
A, DELETE statement(1) Conditional deletion
Syntax format: delete [from] table_name [where co
TRUNCATE TABLE name;Delete from table name;is used to delete all the records in the table, the former delete the data after the table's identity column will restart numbering, it is more than the DELETE statement using the system resources and transaction log resources, but the table structure, columns, constraints, indexes, etc. will not be changed, it cannot be used in a table with a FOREIGN key constrain
elements are essential.
The example is the most image and the most descriptive question. So, not the whole useless, directly into the subject. According to the syntax structure above, I want to delete all the user_name equals Simaopig records in the Firends table, and I can use the following SQL statement:
The code is as follows
Delete from friends where user_name = ' simaopig ';
Delete considerations:
In the MySQL database, both the DELETE statement and the TRUNCATE TABLE statement can be used to delete data, but there are differences between the two statements, the following shows you the difference between the empty MYSQLL table content is common in two ways: a Delete, One is truncate. The DELETE
, place, character, environment and plot elements are essential.
The example is the most image and the most descriptive question. So, not the whole useless, directly into the subject. According to the syntax structure above, I want to delete all the user_name equals Simaopig records in the Firends table, and I can use the following SQL statement:
The code is as follows
Copy Code
...]
[LIMIT Row_count]
MySQL's syntax is similar to spoken language, you have to point out which table you want to delete data, and delete which data, this is enough. Just like when writing a narrative, time, place, character, environment and plot elements are essential.
The example is the most image and the most descriptive question. So, not the whole useless, directly into the subject. Following the syntax structure above, I want to delete all the user_name equals Simaopig reco
descriptive question. So, not the whole useless, directly into the subject. Following the syntax structure above, I want to delete all the user_name equals Simaopig records in the Firends table,You can use the following SQL statement:
The code is as follows
Copy Code
Delete from friends where user_name = ' Simaopig ';d elete
Note:From the syntax structure, we can see
The TRUNCATE command clears all records in the Table in mysql and resets the table ID. Next I will introduce the usage and instance of TRUNCATE.
Truncate table deletes all rows in the TABLE, but does not record the deletion of a single row.
SyntaxTruncate table name;ParametersName (the name of the table to be truncated or the name of the table to delete all its r
Separate description of database deletion statements:Delete: For deleting rows in a table (note: You can delete a row, or you can delete all rows without deleting the table (that is, the table's structure, properties, index Integrity)
Syntax: Delete a row: Delete from table name Where column name = value
Delete all rows: Delete from table name or delete * from table name
Drop: For deleting a table (note: The structure, properties, and indexes of the table will also be deleted.) )
Syntax: Drop t
TRUNCATE table deletes all rows in a table without recording a single row delete operation.
GrammarTRUNCATE TABLE name;ParametersName (the names of the tables you want to truncate or the names of the tables whose rows you want to delete)TRUNCATE table is functionally the same as a DELETE statement without a WHERE clau
SQL truncate, delete and drop differencesSame point:1.truncate and delete without a WHERE clause, and drop deletes the data in the table.2.drop, truncate are DDL statements (data definition language) that are automatically committed after execution.Different points:1. Truncate
Use the truncate TABLE statement to delete table data
To delete all records in a large table, run the truncate command to release
The data block tablespace used. This operation cannot be rolled back.
Syntax format:
Truncate table table_name
Table_name indicates the name of the table to be deleted. Because the
Transferred from: http://www.studyofnet.com/news/555.htmlThis article follows: The method of deleting data in a table is delete,truncate, where TRUNCATE TABLE is used to delete all rows in the table without logging a single row delete operation. TRUNCATE table is similar to a DELETE statement without a WHERE clause; Ho
Truncate DELETE, drop statement difference
Different points:1. Truncate and delete Delete only the data do not delete the structure of the table (definition)The DROP statement deletes the table's structure-dependent constraints (constrain), triggers (trigger), indexes (index); Stored procedures/functions that depend o
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.