📅  最后修改于: 2023-12-03 14:44:56.003000             🧑  作者: Mango
Oracle TRUNCATE is a SQL command used to quickly and efficiently remove all rows from a table or a cluster. It is an alternative to the DELETE command, but it performs the operation more swiftly by bypassing the transaction log. TRUNCATE is a DDL (Data Definition Language) operation and cannot be rolled back.
The syntax for TRUNCATE is as follows:
TRUNCATE TABLE table_name;
TRUNCATE TABLE employees;
This statement will remove all the rows from the "employees" table, but the table structure and other associated objects will remain unaffected.
TRUNCATE TABLE orders CASCADE;
In this example, the TRUNCATE command will remove all rows from the "orders" table, and because we specified the CASCADE
clause, it will also remove the dependent rows from any child tables that have foreign key constraints pointing to the "orders" table.
TRUNCATE TABLE table1, table2, table3;
The above statement will truncate multiple tables, i.e., "table1", "table2", and "table3" in a single command.
Oracle TRUNCATE is a powerful SQL command that efficiently removes all rows from a table or cluster. It offers performance benefits over the DELETE command and releases storage space as well. Care must be taken while using TRUNCATE as it cannot be rolled back.