The TRUNCATE command in Oracle is used to quickly delete all data in the table. It does not use transaction logs, is fast, and cannot be rolled back. It will reallocate the table space, retain the table definition, and reset the identity column. Compared with DELETE, TRUNCATE is faster, cannot be rolled back, and space will be reallocated.
TRUNCATE Usage in Oracle
TRUNCATE is a command in Oracle that is used to quickly delete all data in a table. Unlike the DELETE statement, TRUNCATE does not use a transaction log, which makes it execute faster.
Syntax
<code>TRUNCATE TABLE table_name;</code>
Usage
TRUNCATE is usually used in the following situations:
Features
The difference between DELETE
The difference between TRUNCATE and DELETE is as follows:
Features | TRUNCATE | DELETE |
---|---|---|
Speed | Faster | Slower |
Can be rolled back | Not rolled back | Can be rolled back |
Space allocation | Reallocate space | Do not reallocate space |
Table definition | Reserved | Reserved |
Identity identification column | Reset | Do not reset |
##Example
The following example will delete all data in tableEMPLOYEES:
<code>TRUNCATE TABLE EMPLOYEES;</code>
Notes
Please note the following when using TRUNCATE:
The above is the detailed content of How to use truncate in oracle. For more information, please follow other related articles on the PHP Chinese website!