Originally posted in 2015. Updated November 2026 for Oracle Database 19c and 21c.
Sometimes a user's temporary tablespace shows a strange name such as _$deleted$12$0. You may notice it when:
- A user's
TEMPORARY_TABLESPACEinDBA_USERSshows a_$deleted$name. - A Data Pump import fails because the user's tablespace does not exist (ORA-00959).
- Scripts that recreate users or grants fail with the same name.
Why it happens
Oracle keeps every tablespace in the data dictionary table SYS.TS$, including dropped ones that something still points to. If you drop a tablespace that users still use as their temporary tablespace, and then create or rename another tablespace with the same name, Oracle renames the old dictionary entry to _$deleted$<ts#>$<n> so the two names do not clash. The users still point to the old, dropped one.
Never update or delete rows in SYS.TS$ yourself. Oracle does not support it, and it can corrupt the dictionary. The fix is always to move the users to a real tablespace.
Reproducing it
I first ran this test on 11g. Try it on a test database for your version; the cleanup steps below are the same in 19c and 21c. In a container database, run it inside a PDB.
-- 1. Check for existing deleted entries (connected as SYS)
SELECT ts#, name FROM sys.ts$ WHERE UPPER(name) LIKE '%DELETED%';
no rows selected
-- 2. Create two temporary tablespaces
CREATE TEMPORARY TABLESPACE temp2 TEMPFILE '/u01/oradata/TESTDB/temp201.dbf' SIZE 100M;
CREATE TEMPORARY TABLESPACE temp3 TEMPFILE '/u01/oradata/TESTDB/temp301.dbf' SIZE 100M;
-- 3. Create a user whose temporary tablespace is TEMP2
CREATE USER junk123 IDENTIFIED BY "Junk#2026" TEMPORARY TABLESPACE temp2;
-- 4. Drop TEMP2, then rename TEMP3 to TEMP2
DROP TABLESPACE temp2;
ALTER TABLESPACE temp3 RENAME TO temp2;
-- 5. The old TEMP2 entry has been renamed in TS$
SELECT ts#, name FROM sys.ts$ WHERE UPPER(name) LIKE '%DELETED%';
TS# NAME
---------- ------------------------------
12 _$deleted$12$0
-- 6. The user still points to the dropped tablespace
SELECT username, temporary_tablespace FROM dba_users WHERE username = 'JUNK123';
USERNAME TEMPORARY_TABLESPACE
---------- ------------------------------
JUNK123 _$deleted$12$0
Finding affected users (19c and 21c)
-- In one database or PDB SELECT username, default_tablespace, temporary_tablespace FROM dba_users WHERE temporary_tablespace LIKE '\_$DELETED$%' ESCAPE '\' OR default_tablespace LIKE '\_$DELETED$%' ESCAPE '\'; -- Across all PDBs, from CDB$ROOT SELECT con_id, username, temporary_tablespace FROM cdb_users WHERE temporary_tablespace LIKE '\_$DELETED$%' ESCAPE '\' ORDER BY con_id, username;
The fix
Move each user to a real temporary tablespace:
ALTER USER junk123 TEMPORARY TABLESPACE temp2; -- Or generate the statements for every affected user SELECT 'ALTER USER "' || username || '" TEMPORARY TABLESPACE temp;' FROM dba_users WHERE temporary_tablespace LIKE '\_$DELETED$%' ESCAPE '\';
Once no user points to it any more, the _$deleted$ entry stops causing problems. It may stay in TS$, and that is harmless.
Data Pump imports
My 2015 post suggested OBJECT_EXISTS_ACTION. That parameter does not exist; the correct ways are:
- Fix the user in the source database before exporting, using the ALTER USER above.
- Or remap the tablespace during import:
REMAP_TABLESPACE=_$deleted$12$0:TEMP(put it in a parameter file to avoid shell quoting problems with the$signs). - Or create the user in the target first, then import with
EXCLUDE=USER. If the tables already exist,TABLE_EXISTS_ACTION=APPENDadds the rows.
How to avoid it
Before dropping any tablespace, move its users first:
SELECT username FROM dba_users WHERE temporary_tablespace = 'TEMP2' OR default_tablespace = 'TEMP2'; -- Make sure the database default temporary tablespace is a real one SELECT property_value FROM database_properties WHERE property_name = 'DEFAULT_TEMP_TABLESPACE';
In 19c and 21c, Oracle will not let you drop the database default temporary tablespace (ORA-12906), but it will still let you drop one that individual users point to. Users you then forget about get the _$deleted$ name.
More current DBA scripts are in my GitHub repository: github.com/sbajwa55/dba-scripts. For help with Oracle administration or migrations to AWS, visit Bajwa Consulting Services.

No comments:
Post a Comment