Home>Article>Database> How to clear table data in oracle

How to clear table data in oracle

王林
王林 Original
2021-01-20 14:42:55 64687browse

Oracle method to clear table data: You can clear the entire table data by using the [delete table_name;] or [Truncate [table] table_name;] statement.

How to clear table data in oracle

The operating environment of this article: windows10 system, oracle 11.2.0.1.0, thinkpad t480 computer.

(Learning video sharing:Introduction to Programming)

Specific method:

When the data in the table is no longer needed, the data should be deleted and To release the occupied space and delete data in the table, you can use the Delete statement or the Truncate statement.

1. Delete statement

1. Conditional deletion

Syntax format:

delete [from] table_name [where condition];

For example: delete the userid of '001' in the users table Data: delete from users where userid='001';

2. Unconditionally delete the entire table data

Syntax format:

delete table_name;

For example: delete all data in the user table :delete users ;

2. Truncate statement

Use the Truncate statement to delete all records in the table.

Syntax format:

Truncate [table] table_name;

1. Delete all records without retaining the space occupied by the records

Truncate [table] table_name [drop storage];

For example: delete all data in the users table without retaining the occupied space: Truncate table users drop storage; Since the drop storage keyword is used by default, drop storage can be omitted;

2. Delete all records and retain the record occupied space

Truncate [table] table_name [reuse storage];

For example: delete all data in the users table and Save occupied space: Truncate table users reuse storage;

Related recommendations:oracle database learning tutorial

The above is the detailed content of How to clear table data in oracle. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn