Khi thao tác DML, DDL (ví dụ khi add partition báo lỗi): '_$deleted$11$0, cụ thể khi thao tác:
Kịch bản bị lỗi:
- Một vùng bảng mới đã được tạo
- Các đối tượng đã được chuyển đến tablespacce
- Tablespacce đã bị xóa
- Tablespacce mới đã được đổi tên để có cùng tên với tablespacce ban đầu đã bị loại bỏ
- DML chống lại một bảng được phân vùng không thành công với ORA-00959
- Thêm partition mới vào bảng partition không thành công với ORA-00959
Ví dụ:
Connect as sysdba
SQL> drop user test cascade;
User dropped.
SQL> drop tablespace oldts including contents and datafiles;
Tablespace dropped.
SQL> create tablespace oldts datafile 'oldts.f' size 10m reuse;
Tablespace created.
SQL> create <username> test identified by <password> default tablespace oldts;
User created.
SQL> grant dba to test;
Grant succeeded.
SQL> connect <username>/<password>;
Connected.
SQL> CREATE TABLE SALES
2 (
3 C1 NUMBER
4 )
5 PARTITION BY RANGE (C1)
6 (
7 PARTITION P1 VALUES LESS THAN (5) NOCOMPRESS
8 , PARTITION P2 VALUES LESS THAN (10) NOCOMPRESS
9 );
Table created.
SQL> col owner format a10
SQL> select owner, table_name,def_tablespace_name
2 from dba_part_tables
3 where owner = 'TEST' and table_name = 'SALES';
OWNER TABLE_NAME DEF_TABLESPACE_NAME
---------- ------------------------------ ------------------------------
TEST SALES OLDTS
SQL> create tablespace newts datafile 'newts.f' size 10M reuse;
Tablespace created.
SQL> alter table test.sales move partition P1 tablespace newts;
Table altered.
SQL> alter table test.sales move partition P2 tablespace newts;
Table altered.
SQL> drop tablespace oldts including contents and datafiles;
Tablespace dropped.
SQL> ALTER TABLESPACE newts RENAME TO oldts;
Tablespace altered.
SQL> select username, default_tablespace, temporary_tablespace from sys.dba_users where username like 'TEST';
USERNAME DEFAULT_TABLESPACE TEMPORARY_TABLESPACE
---------- ------------------------------ ------------------------------
TEST OLDTS TEMP
SQL> col username format a10
SQL> select username, default_tablespace, temporary_tablespace
2 from dba_users where username ='TEST';
USERNAME DEFAULT_TABLESPACE TEMPORARY_TABLESPACE
---------- ------------------------------ ------------------------------
TEST OLDTS TEMP
SQL> select owner, table_name,def_tablespace_name
2 from dba_part_tables
3 where owner = 'TEST' and table_name = 'SALES';
OWNER TABLE_NAME DEF_TABLESPACE_NAME
---------- ------------------------------ ------------------------------
TEST SALES _$deleted$11$0
SQL> alter table sales add partition P3 values less than(25) nocompress;
alter table sales add partition P3 values less than(25) nocompress
*
ERROR at line 1:
ORA-00959: tablespace '_$deleted$11$0' does not exist
SQL> alter table sales modify default attributes tablespace oldts;
Table altered.
SQL> alter table sales add partition P3 values less than(25) nocompress;
Table altered.
SQL> spool off
SQL> drop user test cascade;
User dropped.
SQL> drop tablespace oldts including contents and datafiles;
Tablespace dropped.
SQL> create tablespace oldts datafile 'oldts.f' size 10m reuse;
Tablespace created.
SQL> create <username> test identified by <password> default tablespace oldts;
User created.
SQL> grant dba to test;
Grant succeeded.
SQL> connect <username>/<password>;
Connected.
SQL> CREATE TABLE SALES
2 (
3 C1 NUMBER
4 )
5 PARTITION BY RANGE (C1)
6 (
7 PARTITION P1 VALUES LESS THAN (5) NOCOMPRESS
8 , PARTITION P2 VALUES LESS THAN (10) NOCOMPRESS
9 );
Table created.
SQL> col owner format a10
SQL> select owner, table_name,def_tablespace_name
2 from dba_part_tables
3 where owner = 'TEST' and table_name = 'SALES';
OWNER TABLE_NAME DEF_TABLESPACE_NAME
---------- ------------------------------ ------------------------------
TEST SALES OLDTS
SQL> create tablespace newts datafile 'newts.f' size 10M reuse;
Tablespace created.
SQL> alter table test.sales move partition P1 tablespace newts;
Table altered.
SQL> alter table test.sales move partition P2 tablespace newts;
Table altered.
SQL> drop tablespace oldts including contents and datafiles;
Tablespace dropped.
SQL> ALTER TABLESPACE newts RENAME TO oldts;
Tablespace altered.
SQL> select username, default_tablespace, temporary_tablespace from sys.dba_users where username like 'TEST';
USERNAME DEFAULT_TABLESPACE TEMPORARY_TABLESPACE
---------- ------------------------------ ------------------------------
TEST OLDTS TEMP
SQL> col username format a10
SQL> select username, default_tablespace, temporary_tablespace
2 from dba_users where username ='TEST';
USERNAME DEFAULT_TABLESPACE TEMPORARY_TABLESPACE
---------- ------------------------------ ------------------------------
TEST OLDTS TEMP
SQL> select owner, table_name,def_tablespace_name
2 from dba_part_tables
3 where owner = 'TEST' and table_name = 'SALES';
OWNER TABLE_NAME DEF_TABLESPACE_NAME
---------- ------------------------------ ------------------------------
TEST SALES _$deleted$11$0
SQL> alter table sales add partition P3 values less than(25) nocompress;
alter table sales add partition P3 values less than(25) nocompress
*
ERROR at line 1:
ORA-00959: tablespace '_$deleted$11$0' does not exist
SQL> alter table sales modify default attributes tablespace oldts;
Table altered.
SQL> alter table sales add partition P3 values less than(25) nocompress;
Table altered.
SQL> spool off
Nguyên nhân: Do tablespace này đã bị drop
Giải pháp: Chuyển default tablespace của table, index sang tablespace mới:
1. Kiểm tra dba_part_tables và dba_part_indexes đảm bảo cột def_tablespace_name bắn ra lỗi ORA-00959 ('_$deleted$11$0').
--Kiểm tra bảng:
select owner, table_name, def_tablespace_name
from dba_part_tables
where lower(def_tablespace_name) like 'Þleted%'
OWNER TABLE_NAME DEF_TABLESPACE_NAME
---------- ------------------------------ ------------------------------
TEST SALES _$deleted$11$0
from dba_part_tables
where lower(def_tablespace_name) like 'Þleted%'
OWNER TABLE_NAME DEF_TABLESPACE_NAME
---------- ------------------------------ ------------------------------
TEST SALES _$deleted$11$0
--Kiểm tra index:
select owner, INDEX_NAME, table_name, def_tablespace_name
from dba_part_indexes
where lower(def_tablespace_name) like 'Þleted%';
from dba_part_indexes
where lower(def_tablespace_name) like 'Þleted%';
2. Nếu bảng hoặc index trỏ đến tablespace đã bị xóa, thì đặt lại default tablsapce cho table, view hợp lệ:
alter table {table name} modify default attributes tablespace {valid tablespace name};
alter index (index name) modify default attributes tablespace (valid tablespace name);;
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile: 0902912888
⚡️ Skype: tranbinh48ca
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: http://bit.ly/ytb_binhoraclemaster
👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhoracle
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội
#OracleTutorial #OracleDBA #OracleDatabaseAdministration #học oracle database #oca #ocp #tự học oracle