Home > Database > Oracle > body text

How to clear table data in oracle

王林
Release: 2023-01-13 00:40:17
Original
64871 people have browsed it

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];
Copy after login

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;
Copy after login

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;
Copy after login

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

Truncate [table]  table_name  [drop storage];
Copy after login

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];
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template