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.
Related
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;
i tried to run a stored procedure as follows,
insert into process_state_archive select * from process_state
where tstamp BETWEEN trunc(ADD_MONTHS(SYSDATE, -12)) AND trunc(ADD_MONTHS(SYSDATE, -3))
Got below error :
Error report:
SQL Error: ORA-01654: Kan index WEBDEV.PROCESS_STAT_TSTAMP_ACTION niet uitbreiden met 8 in tabelruimte USERS.
01654. 00000 - "unable to extend index %s.%s by %s in tablespace %s"
*Cause: Failed to allocate an extent of the required number of blocks for
an index segment in the tablespace indicated.
*Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more
files to the tablespace indicated.
But Yesterday i could able to run the procedure without any error.
Can any one please tell me the resolution for the above error ?
Your USERS tablespace is full. You may be able to free up some space by dropping something, possibly old objects - if this is a development environment in particular, see if you've been accumulating old objects in the recycle bin and purge any you no longer require.
If you can't fee up any space then you need to do what the error message tells you to do, add an additional data file to the tablespace, or increase the size of an existing data file, assuming you have sufficient disk space to do so.
The documentation has a section about managing data files, including adding data files and changing the size of existing data files. Which action is appropriate will depend on your circumstances, and you'll need to decide what size is appropriate. You might also want to consider creating a new dedicated tablespace for your application rather than using the USERS tablespace, but again depends on your circumstances and needs.
I have some cache tables that are already empty by a delete, if I try to truncate a table with the DROP STORAGE option, the memory will be free?
From the documentation:
By default, Oracle Database also performs the following tasks:
Deallocates all space used by the removed rows except that specified by the MINEXTENTS storage parameter
The DROP STORAGE option has exactly the same effect as it is the default.
I've got this table with millions of rows that I loaded via the append hint.
Now I go to turn the constraints back on, I get the following:
2012-03-23 01:08:53,065 ERROR [SQL] [main]: Error in executing SQL:
alter table summarydata add constraint table_pk primary key (a, b, c, d, e, f)
java.sql.SQLException: ORA-30032: the suspended (resumable) statement has timed out
ORA-01652: unable to extend temp segment by 128 in tablespace MY_TEMP_TABLESPACE
Are there any best practices to avoid this? I'm adding some more datafiles, but why would this even be a problem?
The error is related to the temporay tablespace, not the data tablespace that holds the table and/or the primary key. You need to increase the size of the MY_TEMP_TABLESPACE so it has enough space to do the comparison, as #Lamak indicated.
If you don't know bow much space it wil need the you can turn AUTOEXTEND on as #DCookie said, and if it already on (for the temp, not data, tablespace!) then check the MAXSIZE setting and increase if necessary. On some platforms the maximum size of a datafile (or for a temp tablespace, hopefully a tempfile) is constrainted so you may need to add additional tempfiles.
If this is a one-off task and you don't want temp to stay big you can shrink it afterwards, but you also have the option to: create a new, large temporary tablespace; modify the user so it uses that instead; build the constraint; modify the user back to the original temp area; drop the new, large temp tablespace.
Any reason why you can't turn AUTOEXTEND on for the tablespace?
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...