I have some strange constraints on strange table on my oracle database named BIN$DHUs7v8fwyvgUAB/AQAHZQ==$0
I cannot drop these constraints. I am getting the following error:
ORA-38301: Can not perform DDL/DML over objects in Recycle Bin
These are tables within the Recycle Bin of the database, with other words, those tables have been dropped. To purge them use:
purge recyclebin;
You can find more about the PURGE command in the Oracle Database documentation.
Oracle recycle bin is a special part of the data dictionary that stores removed objects in a fashion that allows them to later be recovered.
These objects (named BIN$unique_id$version, like the object in the question) can be manipulated directly, but instead should be purged from the recycle bin:
PURGE INDEX BIN$DHUs7v8fwyvgUAB/AQAHZQ==$0
you need to disable the oracle recyclebin, delete the object and then enable it again
ALTER SYSTEM SET recyclebin = OFF;
--delete object
ALTER SYSTEM SET recyclebin = on;
Related
We are thinking in create a housekeeping program to delete old partitions from HIVE tables. After reading the documentation, I found that you can establish a retention period using SET TBLPROPERTIES.
ALTER TABLE employees SET TBLPROPERTIES ('discover.partitions'='true');
ALTER TABLE employees SET TBLPROPERTIES ('partition.retention.period'='7d');
My questions are the following:
After executing this command HIVE will delete old partitions ? In
other systems, normally setting properties don't affect to existing
elements.
When this clean-up takes place ? I did not see a way to configure it ? What happens if someone is accessing the partition in the moment the process is triggered ?
Or it's just best to just create an script to read the metadata dictionary
in HIVE and delete old partitions ?
Thanks for your help!
I'm new to this Oracle Database. Today I ran DROP TABLE table1; and tried to FLASHBACK it. But the Script Output returned this :
FLASHBACK TABLE TABLE1 TO BEFORE DROP
Error report -
ORA-38305: object not in RECYCLE BIN
38305. 00000 - "object not in RECYCLE BIN"
*Cause: Trying to Flashback Drop an object which is not in RecycleBin.
*Action: Only the objects in RecycleBin can be Flashback Dropped.
I thought that the recyclebin was somehow disabled. So I opened another connection and input this command :
ALTER SESSION SET recyclebin = ON;
and repeated the process again, the result was still the same. There was nothing in the recyclebin when I ran SELECT * FROM RECYCLEBIN;
Did I unintentionally mess up anything ?
The technique you're using is Oracle Flashback Drop. It's enabled when satisfying the following three conditions:
Parameter RECYCLEBIN='on'
Data not being stored in SYSTEM tablespace
Data must be stored in a locally managed tablespace
I guest that you're simulating your examples under SYS user (which has the default tablespace SYSTEM) leading to you can't flachback at all.
I did try to login as SYS user and simulating a small example as yours and do get the same error output as yours.
Try your lab under another user which default tablespace not SYSTEM.
You can verify the conditions by checking:
Recleclebin='on' with SQL*PLUS SQL> SHOW PARAMETER RECYCLEBIN;
Default Tablespace not SYSTEM with SQL> select default_tablespace
from dba_users where username='input_username';
Tablespace datafile is locally managed with SQL>select
extent_management from dba_tablespaces where
tablespace_name='input_tablespace_name';
you didn't mess up anything with the command ALTER SESSION SET recyclebin = ON; but it's late to invoke that command. I think your problem is due your default tablespace to be SYSTEM for tables.
Oracle Flashback Drop reverses the effects of a DROP TABLE operation. It can be used to recover after the accidental drop of a table. Flashback Drop is substantially faster than other recovery mechanisms that can be used in this situation, such as point-in-time recovery, and does not lead to any loss of recent transactions or downtime.
The table and its dependent objects will remain in the recycle bin until they are purged from the recycle bin. You can explicitly purge a table or other object from the recycle bin with the command:
DROP TABLE some_table PURGE;
Dropped objects are kept in the recycle bin until such time as no new extents can be allocated in the tablespace to which the objects belong without growing the tablespace. This condition is referred to as space pressure. Space pressure can also arise due to user quotas defined for a particular tablespace. A tablespace may have free space, but the user may have exhausted his or her quota on it.
When space pressure arises, the database selects objects for automatic purging from the recycle bin. Objects are selected for purging on a first-in, first-out basis, that is, the first objects dropped are the first selected for purging.
There is no fixed amount of space preallocated for the recycle bin. Therefore, there is no guaranteed minimum amount of time during which a dropped object will remain in the recycle bin.
To view only objects in the recycle bin, use the USER_RECYCLEBIN and DBA_RECYCLEBIN views.
Whenever I perform select * from tab; I get tables that i did not create.
It looks like:
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
BIN$GGrKjbVGTVaus4568IEhUQ==$0 TABLE
BIN$H+a0o3uyTTKTOA8WMkNltg==$0 TABLE
BIN$IUNyfOwkS0WSEVjbn04mNw==$0 TABLE
BIN$K/3NJw5zRXyRqPixL3tqDA==$0 TABLE
BIN$KQw9SejEToywXlHp18FMZA==$0 TABLE
BIN$MOEfgWgsS0GkC/CpYW+cxA==$0 TABLE
BIN$QkUYVciPQpWBwqBhxH+Few==$0 TABLE
BIN$QmtbaOYiTHCGEE0PRiLzmg==$0 TABLE
BIN$QxF4/JShTxu8PYIx8g/L7Q==$0 TABLE
BIN$UtEI7RbiQvOYzKqJEibwKQ==$0 TABLE
BIN$VMG0FXp2ROCKbedj3Ge9hg==$0 TABLE
I tried performing
select 'drop table '||table_name||' cascade constraints;' from user_tables;
on spool and executing but those table were not selected. It just looks really messy and is bothering me a lot. What are they? Is there any way I can get rid of them ? Or do I have to just deal with it and work with it?
Q What are they?
A Looks like tables that were dropped and preserved in the RECYCLEBIN.
Q Is there any way I can get rid of them ?
A You can use e.g. PURGE TABLE BIN$GGrKjbVGTVaus4568IEhUQ==$0 ; to remove them.
That will do them individually. Note that indexes and LOBs (and other out-of-line storage) may also have entries in the recycle bin. There are other statements you can use to clear out all entries from the recycle bin.
Q Or do I have to just deal with it and work with it?
A That's up to you.
There are statements to purge the recycle bin for the current user, or if you have privileges, for the entire database. You can also disable the recyclebin, or ( I think) there's an option on the DROP TABLE that will drop a table without keeping it in the recyclebin (so these won't be created in the future.)
There's no need for me to repeat the contents of the Oracle documentation.
Refer to: http://docs.oracle.com/cd/B28359_01/server.111/b28310/tables011.htm#ADMIN01511
Posting as a comment for better visibility..
Credits to #Tomás for pointing me in the right direction.
I had to do
purge recyclebin;
instead of purge dba_recyclebin since I have insufficient privilege(I am a student logged in via ssh).
If you want to turn your recycle bin off, Use ALTER SESSION SET recyclebin = OFF;
We have a shell script that perform a physical backup of our oracle database (tar + compress of all our database files). Recently, we created a tablespace containing tables that we dont need to backup its contents.
Is it possible to ignore data files relative to this tablespace and have a valid backup?
PS: we don't want to use RMAN.
I preface my remarks here with a note: this is NOT the normative pattern. Normally, we use RMAN to backup ALL the datafiles in the database. With that said...
Yes, it may be possible to restore and recover the database from a backup with a m ssing datafile. But the recovery will require that the tablespace be dropped when the database is restored.
For the simple case of a dropping a tablespace that contains a single datafile: first restore the database files, then:
STARTUP NOMOUNT;
ALTER DATABASE MOUNT ;
ALTER DATABASE DATAFILE '<complete_path_to_datafile>' OFFLINE DROP ;
ALTER DATABASE OPEN ;
DROP TABLESPACE <tablespace_name> INCLUDING CONTENTS ;
Then, continue with database recovery ( RECOVER DATABASE ; )
Obviously, the tablespace_name you provide in the DROP TABLESPACE command would be the one related to the datafile that is dropped.
Obviously, this wouldn't work for the SYSTEM tablespace. And I wouldn't dare try this on other tablespaces like UNDO, SYSAUX, USERS. And there's different syntax for dropping and adding TEMPORARY TABLESPACES.
I don't know of any "gotchas" with the 'DROP TABLESPACE ... INCLUDING CONTENTS', but consider that objects in other tablespaces could be impacted. (Consider that the dropped tablespace might have indexes for tables in other tablespaces, impacts on foreign key constraints, impacts on stored procedures, and so on.)
And it goes without saying, that you would need to test this type of restore procedure in a test environment before you rely on this technique in production.
Without testing, you would be much better served by using RMAN to backup ALL of the datafiles.
NOTE: I have not done anything like this since Oracle 8, possibly Oracle 7.3 (back when we had to roll our own hotbackup scripts). Since we've started using RMAN, I haven't had a need to test anything like this.
NOTE: The RECOVER DATABASE may need to be run before the ALTER DATABASE OPEN. I think you may get an exception warning about "datafile needing more recovery", like you do when you start the database when a tablespace has been left in BEGIN BACKUP mode...
Whats options do I have to clear the schema and data from a MDF file? What options to delete all the data?
To reset a databases schema, it seems I need to copy a file from a backup of the database when it was empty. I was wondering if there was a simpler or more efficient way.
To clear all data, it seems I'd need to write a script. The script would disable constraints, then drop all rows from each table before turning back on constraints. This is straightforward but does require I discover/track what tables exist in the database. Maybe its not sufficient or there is an easier approach?
I'm not sure what the point is of 'clearing the schema' - surely a new database already has a 'clear' schema.. BUT, you can create a new database in code via the following T-SQL:
USE Master
CREATE DATABASE NewDb (NAME=NewDbFile, FILENAME= '<filepath>')
If you need a file (an MDF) you can then detach the database too with sp_detach_db and you can then move it as required from the location specified above:
EXEC sp_detach_db NewDb
To clear the data you can use sp_msforeachtable with a truncation command - it is a non-logged operation, and does not check constraints, nor foreign keys - however, it cannot be rolled back!
EXEC sp_msforeachtable 'TRUNCATE TABLE ?'