Home > Database > Oracle > body text

What are the delete statements in oracle

WBOY
Release: 2022-06-10 18:53:08
Original
21997 people have browsed it

Delete statement: 1. "delete from table name where condition" statement, use delete to delete table data; 2. "truncate table table name" statement, use truncate command to delete data; 3. "Drop Table table name" ", use Drop to delete the table.

What are the delete statements in oracle

The operating environment of this tutorial: Windows 10 system, Oracle version 12c, Dell G3 computer.

What are the delete statements in oracle

Delete statements Drop, Delete, Truncate

1. Deletion of table data is using Delete command.

delete command structure:

delete from 表名 where 条件
Copy after login

is used to delete rows in the table (note: a row can be deleted; it can also be deleted without deleting the table (that means the table Structure, attributes, and indexes are complete) Delete all rows)

Delete the data of student "Zhang San" in the student information table (stuinfo):

What are the delete statements in oracle

2. The truncate command is also a data deletion command

It is a command that directly deletes Oracle table data at once. The truncate command is a DDL command, unlike delete, which is a DML command.

Used to delete data in the table (Note: only delete the data in the table, not the table itself, which is equivalent to the Delete statement without writing the Where clause)

truncate command structure:

truncate table 表名;
Copy after login

Delete student information backup table (stuinfo_2018):

What are the delete statements in oracle

What are the delete statements in oracle

##3. Drop: used to delete the table (Note: The structure, attributes, and indexes of the table will also be deleted.)

Syntax:

Drop  Table 表名称
Copy after login

Truncate and delete can delete data in the table. They The difference:

1. TRUNCATE is a DDL command. It is submitted after the command is executed. The deleted data cannot be recovered. The DELETE command is a DML command. It needs to be submitted after the command is executed to take effect. The deleted data Can be restored through log files.

2. If the amount of data in the table is large, TRUNCATE is much faster than DELETE.

3. Truncate deletion will reset the initial size of the table index, but delete cannot.

4. Delete can trigger the related delete trigger on the table, but truncate will not trigger.

5. The principle of delete is to delete data from the table one at a time, and record the deletion operation as a transaction in the database log for data rollback. Truncate deletes data pages all at once, so the execution speed is fast, but it cannot be rolled back.

In terms of speed, generally drop>truncate>delete.

Recommended tutorial: "

Oracle Video Tutorial"

The above is the detailed content of What are the delete statements 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