Oracle recycle bin, ora-38301 Error

Source: Internet
Author: User
Ora-38301 error, recycle bin

A colleague told me a few days ago that there was a serverTablespaceCannot be deleted. Let's see. Log on to the server and delete the tablespace,DatabaseSame timeOra-00604AndOra-38301Error. At first, I thought that a database object was locked. After I restarted the database, I found that the same error was still reported. Google may find a new feature with 10 GBRecycle BinRelated: Clear the recycle binPurge RecyclebinAfter the deletion, the same error is returned. You cannot delete a tablespace after the tablespace is offline. You may want to see if any associated objects are not cleared or are still in use. When you delete a user before the tablespace is deleted, you are prompted to delete the associated objects. Delete a user first. When you delete a user, you can delete the associated cascade objects and then delete the tablespace. I also knowOracleA new feature of 10 Gb.

Oracle10g provides the recycle bin function similar to the operating system. In principle, the recycle bin is a data dictionary table that stores information about database objects dropped by users. When you drop a table, you only need to rename it and put the table and associated objects such as index and constraint in the recycle bin. If you find that the table is dropped incorrectly, you can use the flashback table name to restore the table in the recycle bin. This is the flashback drop function of Oracle10g.

1. enable/disable recyclebin:

By setting the initialization parameter recyclebin, you can determine whether to enable the recycle bin function. By default, the recycle bin function is enabled.
; ': V |} h; W2 ?) L r b0sql> alter system set recyclebin = off;

The system has been changed.

SQL> alter system set recyclebin = on;

The system has been changed.

SQL> alter session set recyclebin = off;

The session has been changed.

SQL> alter session set recyclebin = on;

The session has been changed.

2. view the recycle bin:

SQL> show recyclebin;

Or

SQL> select * From recyclebin;

Unless you have sysdba permissions, you can only view your own objects. Therefore, for users, it seems that everyone has their own recycle bin. Even if you have the permission to delete other schema objects, you can only view your own objects in recyclebin.

3. Operations on recycle bin objects:

When a table is deleted and moved to the "recycle bin", its name must be converted. This aims to avoid repeated names of similar objects. (This is different from the recycle bin of a Windows operating system. The recycle bin of a Windows operating system is specially processed, and the operating system file can be renamed .) The converted name format is as follows:

Bin $ unique_id $ version in which bin represents recyclebin, unique_id is the unique identifier of the object in the database, and 26 characters in length version represents the version number of the object.

Note that the following drop statements do not put related objects into recyclebin:

Drop tablespace: clears all objects in recyclebin that belong to this tablespace.

Drop User: clears all objects belonging to this user in recyclebin.

Drop cluster: clears all member objects belonging to the cluster in recyclebin.

Drop type: clears all objects dependent on this type in recyclebin.

L tables that have been placed in the recycle bin cannot be deleted using the drop command (note the double quotation marks on the object name ):

SQL> drop table "bin $ v3f/oyuitrcef2cots5jaa = $0 ";

Drop table "bin $ v3f/oyuitrcef2cots5jaa = $0"

*

Error at line 1:

ORA-38301: can not perform. DDL/DML over objects in Recycle Bin

To clear this object, run the purge command:

SQL> purge table "bin $ v3f/oyuitrcef2cots5jaa = $0 ";

Table purged.

L if you directly clear all objects in the recycle bin:

SQL> purge recyclebin;

Recyclebin purged.

Purge recyclebin can clear all the recyclebin objects that can be seen by the user who executes this command. That is, normal users can clear their own objects, while sysdba users can clear all objects in recyclebin.

L restore the table and use the flashback table function:

SQL> flashback table table_name to before drop;

Flashback complete.

The first deleted table is restored by default. If you want to restore the specified table, you can add the specified recyclebin parameter after the flashback table to specify other names:

Statement flashback table [Deleted table name | "name in recyclebin"] To before drop;

However, when you have two tables with the same name in recyclebin, only the specified table is flashed back through "name in recyclebin, in the above method, only the first table to be deleted is flashed back.

L purge tablespace tablespace_name can clear all objects in the specified tablespace that recyclebin belongs. Itpub personal space 0? M} 0 ~ + P x4a J
SQL> purge tablespace users;

The tablespace has been cleared.

Purge tablespace tablespace_name user user_name can clear all objects belonging to the specified tablespace and specified user in recycle. Itpub personal space 3q + S q E Z
SQL> purge tablespace users user Ning;

The tablespace has been cleared.

L when clearing a table, the constraints dependent on the table are also cleared, such as the index. You can specify to clear only the corresponding constraints of the table, for example, purge index idx_test.

Objects such as indexes and triggers on a table are not flashed back after the table is flashed back, but are kept in the recycle bin name. Some code objects dependent on this table, such as views and stored procedures, will expire after the table is deleted, and will not be automatically re-compiled after the table is flashed back, but will need to be re-compiled manually. The related information is stored in the user_recycle view. You can use the following statement to obtain the original names of these indexes and trigger objects:

1 SQL> select object_name, original_name, Type

2 from user_recyclebin
A4}) a r 'd + C $ l e. F0 3 where base_object = (select base_object from user_recyclebin
_) Z7r (? Z0 4 where original_name = 'abc ')
M m4x Z # B; O J0 5 and original_name! = 'Abc ';
8 ~ : _] $ G s S0 object_name original_n type
3 T u0d; r4c "q0] $ l0 ------------------------------------------------
$ U q p C, L; y4l + K (u) '0 bin $1 + + ilvsqq7mfph2pvont5a ==$ 0 idx_test Index

You can use the following methods to restore an index:

SQL> alter Index "bin $1 + + ilvsqq7mfph2pvont5a = $0" RENAME to idx_test;

One exception is that the bitmap index is not saved in the recycle bin after it is deleted, and cannot be found from the preceding view. You need to use other methods to restore it.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.