Truncate usage in oracle and oracletruncate usage
Truncate in oracle
Syntax: truncate table;
You can use the truncate Statement (DDL language) to delete all records in a table. The truncate statement is usually much faster to delete data than to delete data. This is because no rollback information is generated when the truncate statement is used to delete data. Therefore, the truncate statement cannot be rolled back, there are few system and transaction log resources used.
The DELETE statement deletes a row at a time and records one row in the transaction log. Truncate table deletes data by releasing the data pages used to store TABLE data, and only records the release of pages in transaction logs.
You can also use the reuse storage keyword in the truncate statement to indicate the space occupied by the record after the record is deleted. In contrast, if you use the drop storage keyword, this indicates that the space occupied by the deleted record is recycled immediately. The drop storage keyword is used by default.
SQL> create table tt (
2 tid number (4)
3 );
SQL> insert into tt values (1 );
One row has been created.
SQL> insert into tt values (2 );
One row has been created.
SQL> insert into tt values (3 );
One row has been created.
SQL> insert into tt values (4 );
One row has been created.
SQL> insert into tt values (5 );
One row has been created.
SQL> truncate table tt reuse storage;
The table is truncated.
SQL> select * from tt;
Unselected row