Recycle Bin

来源:互联网 发布:数据库语言获取日期 编辑:程序博客网 时间:2024/06/13 04:53

What Is the Recycle Bin?

The recycle bin is actually a data dictionary table containing information about dropped objects. Dropped tables and any associated objects such as indexes, constraints, nested tables, and the likes are not removed and still occupy space. They continue to count against user space quotas, until specifically purged from the recycle bin or the unlikely situation where they must be purged by the database because of tablespace space constraints.

 recycle bin 是一张包含被删除对象信息的数据字典表,包括被删除表、索引、约束等,这些对象没有真正被删除并一直占用着空间。可以用purge删除 recycle bin中的对象,或是当表空间容量不够用时,会自动清空recycle bin,但这种情况不太可能发生

Each user can be thought of as having his own recycle bin, because, unless a user has the SYSDBA privilege, the only objects that the user has access to in the recycle bin are those that the user owns. A user can view his objects in the recycle bin using the following statement:

每一个用户只能看到属于自己的被删除的对象,除非该用户拥有sysdba的 权限。

When you drop a tablespace including its contents, the objects in the tablespace are not placed in the recycle bin and the database purges any entries in the recycle bin for objects located in the tablespace. The database also purges any recycle bin entries for objects in a tablespace when you drop the tablespace, not including contents, and the tablespace is otherwise empty. Likewise:

当你使用连同content一起删除表空间时,那么这个表空间上的回收站的里的对象会被删除.

  • When you drop a user, any objects belonging to the user are not placed in the recycle bin and any objects in the recycle bin are purged.

当删除一个用户时,回收站中属于这个用户的对象会被清空

  • When you drop a cluster, its member tables are not placed in the recycle bin and any former member tables in the recycle bin are purged.

删除一个cluster,回收站中属于这个cluster的成员表会被删除

  • When you drop a type, any dependent objects such as subtypes are not placed in the recycle bin and any former dependent objects in the recycle bin are purged.

删除一个type是,回收站中依赖这个type的subtype会被删除


Object Naming in the Recycle Bin

When a dropped table is moved to the recycle bin, the table and its associated objects are given system-generated names. This is necessary to avoid name conflicts that may arise if multiple tables have the same name. This could occur under the following circumstances:

当一个被删除的表移到回收站后,系统自动给他生成一个名字,这个名字必须避免以下两种冲突

  • A user drops a table, re-creates it with the same name, then drops it again.

  • Two users have tables with the same name, and both users drop their tables.

The renaming convention is as follows:

BIN$unique_id$version

  • Unique_id is a 26-character globally unique identifier for this object, which makes the recycle bin name unique across all databases

  • version is a version number assigned by the database

Enabling and Disabling the Recycle Bin

When the recycle bin is enabled, dropped tables and their dependent objects are placed in the recycle bin. When the recycle bin is disabled, dropped tables and their dependent objects are not placed in the recycle bin; they are just dropped, and you must use other means to recover them (such as recovering from backup).

Disabling the recycle bin does not purge or otherwise affect objects already in the recycle bin. The recycle bin is enabled by default.

禁用 recycle bin, recycle bin中已有的对象不会被清除,recycle bin功能默认是开启的

You enable and disable the recycle bin by changing the recyclebin initialization parameter. This parameter is not dynamic, so a database restart is required when you change it with an ALTER SYSTEM statement.

recyclebin不是动态参数,需要重启才能起效


Restoring Tables from the Recycle Bin

Restoring Dependent Objects

When you restore a table from the recycle bin, dependent objects such as indexes do not get their original names back; they retain their system-generated recycle bin names. You must manually rename dependent objects to restore their original names. If you plan to manually restore original names for dependent objects, ensure that you make note of each dependent object's system-generated recycle bin name before you restore the table.

当你从recycle bin中恢复一个表时,依赖的对象例如索引不会回到原始的名字,你必须手动恢复他们的名字

SQL> create table huang(id int) ;Table created.SQL> create index id_indx on huang(id);Index created.SQL> drop table huang;Table dropped.SQL> show recyclebinORIGINAL NAME    RECYCLEBIN NAME                OBJECT TYPE  DROP TIME---------------- ------------------------------ ------------ -------------------HUANG            BIN$C33iYIh/OZDgUKjAgOkE9w==$0 TABLE        2014-12-31:02:40:09
SQL>  flashback table  huang to before drop;Flashback complete.
SQL> select  INDEX_NAME,INDEX_TYPE from user_indexes where TABLE_NAME='HUANG';INDEX_NAME------------------------------------------------------------INDEX_TYPE------------------------------------------------------BIN$C33iYIh+OZDgUKjAgOkE9w==$0NORMALSQL> ALTER INDEX "BIN$C33iYIh+OZDgUKjAgOkE9w==$0" RENAME TO HUANG;Index altered.SQL> select  INDEX_NAME,INDEX_TYPE from user_indexes where TABLE_NAME='HUANG';INDEX_NAME------------------------------------------------------------INDEX_TYPE------------------------------------------------------HUANGNORMAL




0 0
原创粉丝点击