Oracle 中删除和删除清除之间的区别
我正在使用 Oracle 数据库,但我对删除和清除命令有点困惑。事实上对我来说两者都做同样的事情。从数据库中删除具有架构的表。这两者之间的主要区别是什么?
- 删除表表名;
- 删除表表名清除;
I am using Oracle Database and I am a bit confused about Drop and Purge Commands. In fact for me both does the same thing. Removes the table with schema from database. What is the main difference between these two?
- Drop Table Tablename;
- Drop Table Tablename Purge;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
通常,如果表被删除,则会将其移至回收站(从 Oracle 10g 开始)。但是,如果还指定了 purge 修饰符,则该表将从数据库中(完全)不可恢复地删除。
Normally, a table is moved into the recycle bin (as of Oracle 10g), if it is dropped. However, if the purge modifier is specified as well, the table is unrecoverably (entirely) dropped from the database.
Oracle 数据库 10g 引入了删除表的新功能。当你
删除一个表后,数据库不会立即释放与该表关联的空间
桌子。相反,数据库会重命名该表并将其放置在回收站中,这样它就可以
如果您发现您稍后可以使用 FLASHBACK TABLE 语句恢复
错误地删除了该表。
如果想立即释放当时与表关联的空间
您发出 DROP TABLE 语句,然后包含 PURGE 子句,如下所示。
删除表中的员工并进行清除;
仅当您要删除表并释放空间时才指定 PURGE
只需一步即可与其关联。如果指定 PURGE,则数据库不会
将表及其依赖对象放入回收站。
注意:您无法使用 PURGE 回滚 DROP TABLE 语句
子句,并且如果使用 PURGE 子句删除表,则无法恢复该表。这
早期版本中不提供此功能。
Oracle Database 10g introduces a new feature for dropping tables. When you
drop a table, the database does not immediately release the space associated with the
table. Rather, the database renames the table and places it in a recycle bin, where it can
later be recovered with the FLASHBACK TABLE statement if you find that you
dropped the table in error.
If you want to immediately release the space associated with the table at the time
you issue the DROP TABLE statement, then include the PURGE clause as follows.
DROP TABLE employees PURGE;
Specify PURGE only if you want to drop the table and release the space
associated with it in a single step. If you specify PURGE, then the database does not
place the table and its dependent objects into the recycle bin.
NOTE: You cannot roll back a DROP TABLE statement with the PURGE
clause, and you cannot recover the table if you drop it with the PURGE clause. This
feature was not available in earlier releases.
Asktom 文章的链接:http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:32543538041420
基本上在oracle10中,所有删除的表都会进入回收状态可以将它们从垃圾箱中取出。通过清除,您基本上会跳过回收站部分,并且删除表,而没有撤消操作的选项。
A link to asktom article: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:32543538041420
Basically with oracle10, all dropped tables go into recycle bin from where they can be undropped. With purge you basically skip the recycle bin part and you drop the table without an option to undo the action.
从@Randy评论中可以清楚地看到,只需补充一下:
(1)Drop Table Tablename:
没有
purge
,表可以位于RECYCLEBIN或USER_RECYCLEBIN中;可以使用命令FLASHBACK
恢复。这类似于我们在 Windows 桌面中删除的文件,这些文件会移至回收站,并且可以恢复回来。(2) Drop Table Tablename Purge:
如果
Drop
与Purge
一起给出,则其表空间被释放且无法恢复。 (就像桌面上的Shift+Delete)以下示例给出了实际示例:
It’s clear from @Randy comment, just to add on:
(1) Drop Table Tablename:
Without
purge
, the table can be in the RECYCLEBIN or USER_RECYCLEBIN; which can be restored using the commandFLASHBACK
. This is similar to files we delete in our windows desktop, which move to the recycle bin, and can be restored back.(2) Drop Table Tablename Purge:
If
Drop
is given along withPurge
, its tablespace is released and cannot be restored. (Like Shift+Delete in desktop)Following example gives practical example:
该命令删除名为table_name的表,但在内部它被移动到oracle的回收站(这与Windows操作系统上使用Delete键删除任何文件/文件夹类似)。
好处:
1. 如果需要,我们将能够恢复上面删除的表。
缺点:
1.仍然占用一定的内存。
此命令从数据库中完全删除表 table_name (类似于在 Windows 操作系统上使用 Shift + Delete 键删除任何文件/文件夹)。
优点和缺点与上述相反。
This command deletes the table named table_name, but internally it is moved to recycle bin of oracle (which is just similar to deleting any file/folder using Delete key on windows os).
Benefits:
1. We will be able to restore the above deleted table if required.
Drawbacks:
1. Still occupies some amount of memory.
This command deletes the table table_name completely from the database (which is similar to deleting any file/folder using Shift + Delete key on windows OS).
The Benefits and Drawbacks will be vice-verse of the above.
下面的语句将删除该表并将其放入回收站。
DROP TABLE emp_new;
下面的语句将删除该表并将其从回收站中清除。
删除表 emp_new PURGE;
The below statement will drop the table and place it into the recycle bin.
DROP TABLE emp_new;
The below statement will drop the table and flush it out from the recycle bin also.
DROP TABLE emp_new PURGE;
如果您不使用回收站,或者知道它存在,则使用 PURGE 选项的替代方法是关闭正在删除表的会话的回收站。
更改会话设置回收站 = 关闭;
If you don't use the recycle bin, or know that it exists, an alternative to using the PURGE option is to turn of the recycle bin for the session that is dropping tables.
ALTER SESSION SET RECYCLEBIN = OFF;
删除表 table_name 清除;
通过使用此查询发生了什么:-
通常,如果表被删除,它会被移入回收站(从 Oracle 10g 开始)。但仍然占用数据库中的内存,因此要释放另一个对象的内存,我们可以使用 Purge 子句。
drop table table_name purge;
By using this query what happened:-
Normally, a table is moved into the recycle bin (as of Oracle 10g), if it is dropped.But still occupied the memory in database so to release the the memory for another object we can use the the Purge clause.