Tablespace
issues with rename to deleted tablespaces
Occasionally you will run into an issue like
A.
A user has a temporary tablespace called
“%dele%’
a. Alter
the user to an existing temporary tablespace.
B.
A data pump import fails because “%delete%’
tablespace does not exist
a. Create
the empty object in correct tablespace and use OBJECT_EXISTS_ACTION=APPEND with
data pump.
C.
Other issues with “%delete%” tablespace.
Oracle data dictionary has a table called ts$ which keeps
the name of all tablespaces (even the deleted one’s to keep the TS# a unique
number) which oracle claims that some object somewhere could still be referring
to that tablespace. When oracle starts the
instance it reads the control file to match ts$ and controlfile with datafile
header to open the database. Oracle
recommends to never touch ts$ table (deleting dropped tablespace from this
table is not supported by oracle). Here is the test I performed
1. See if
you have any tablespaces in ts$ that are called “%dele%”
SQL>
select ts#,name from ts$ where upper(name) like '%DELE%'
2 /
no
rows selected
2. Create
two temporary tablespaces
SQL>
create temporary tablespace temp2 tempfile
'/u01/app/oracle/oradata/testdba/temp201.dbf' size 100m
2 /
Tablespace
created.
SQL>
create temporary tablespace temp3 tempfile
'/u01/app/oracle/oradata/testdba/temp301.dbf' size 100m
2 /
Tablespace
created.
3. Create
a user that temp2 as default.
SQL>
create user junk123 identified by junk temporary tablespace temp2;
User
created.
4. Drop
the temp2 tablespace and rename temp3 to temp2.
SQL>
drop tablespace temp2;
Tablespace
dropped.
SQL>
alter tablespace temp3 rename to temp2;
Tablespace
altered.
5. Check
the ts$ table
SQL> select ts#,name from ts$ where name like
‘%dele%’
2 /
TS# NAME
----------
------------------------------
12 _$deleted$12$0
6. Check
the user.
SQL>
select username,temporary_tablespace from dba_users where username=’JUNK123’;
USERNAME TEMPORARY_TABLESPACE
------------------------------
----------------------------
JUNK123 _$deleted$12$0
7. Check
the ts$ to see that %dele% is still there even as we have dropped the
tablespace.
SQL>
select ts#,name from ts$ where name like ‘%dele%’
2 /
TS# NAME
----------
------------------------------
12 _$deleted$12$0

No comments:
Post a Comment