Several ways to delete a table in Oracle

Source: Internet
Author: User


Several ways to delete a table in Oracle: DELETE the table (record and structure) language name DELETE ---- truncate ---- drop delete (DELETE the statement recorded in the data table) www.2cto.com delete from table name WHERE condition; note: deleting a record does not release the occupied data block tablespace in ORACLE. it only marks the deleted data blocks as unused. if you want to delete all records in a large TABLE, you can use the TRUNCATE command to release the truncate table Name of the occupied data block tablespace. This operation cannot be rolled back. in the same point, truncate, delete without where clause, and drop both delete data in the table. Note: delete here refers to the differences between delete statements without where clause: 1. the truncate and delete statements that only delete data and do not delete the table's structure (Definition) drop statement will delete the constraints (constrain), triggers (triggers), and indexes (indexes) that the table structure is dependent on ); stored Procedures/functions dependent on the table will be retained, but will change to the invalid state. 2. the delete statement is dml, which is put into the rollback segement and takes effect only after the transaction is committed. If a trigger exists, it is triggered during execution. truncate, drop is ddl, and the operation takes effect immediately. The original data is not placed in rollback segment and cannot be rolled back. trigger is not triggered. 3. the delete statement does not affect the extent and high watermark used by the table) keep the original location unchanged. Obviously, the drop statement will release all the space occupied by the table. The truncate statement defaults to the minextents extent, unless you use reuse storage; truncate will reset the high water line (back to the beginning ). 4. speed, in general: drop>; truncate>; delete 5. security: Use drop and truncate with caution, especially when no backup is available. otherwise, you will not be able to use it when you cry. If you want to delete some data rows, use delete. Note that the where clause is included. the rollback segment must be large enough. to delete a table, use drop to retain the table and delete all data. if it is irrelevant to the transaction, use truncate. if it is related to the transaction or you want to trigger the trigger, delete is used. if you are sorting out the fragments in the table, you can use truncate to keep up with the reuse stroage, and then re-import/insert data to oracle to delete a column of statements in the table alter table Name drop colum column name
 

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.