Версия:
+ |
SQL> select *
2 from v$version
3 /
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL>
|
Почему-то считал что partition exchange будучи физической операцией выдаст ошибку если сессия 1 откроет курсор на выборку из партиции затем сессия 2 сделает partition exchange после чего сессия 1 попытается фетчить из курсора. Т.е. примерно то же что и с truncate:
+ |
SQL> -- session 1
SQL> truncate table range_sales;
Table truncated.
SQL> insert
2 into range_sales
3 select level,1,date '2000-02-01','A',1,1,1
4 from dual
5 connect by level <= 100
6 /
100 rows created.
SQL> commit;
Commit complete.
SQL> variable v_cur refcursor
SQL> exec open :v_cur for select * from range_sales partition(sales_q1_2000);
PL/SQL procedure successfully completed.
|
+ |
SQL> -- session 2
SQL> alter table range_sales truncate partition sales_q1_2000; -- OR: truncate table range_sales;
Table truncated.
SQL>
|
+ |
SQL> -- session 1
SQL> print v_cur
ERROR:
ORA-08103: object no longer exists
|
Oднако:
SQL> -- session 1
SQL> truncate table range_sales;
Table truncated.
SQL> insert
2 into range_sales
3 select level,1,date '2000-02-01','A',1,1,1
4 from dual
5 connect by level <= 100
6 /
100 rows created.
SQL> commit;
Commit complete.
SQL> variable v_cur refcursor
SQL> exec open :v_cur for select * from range_sales partition(sales_q1_2000);
PL/SQL procedure successfully completed.
SQL> -- session2
SQL> truncate table range_sales_exchange;
Table truncated.
SQL> alter table range_sales
2 exchange partition sales_q1_2000
3 with table range_sales_exchange
4 /
Table altered.
SQL> select count(*)
2 from range_sales_exchange
3 /
COUNT(*)
----------
100
SQL> select count(*)
2 from range_sales partition(sales_q1_2000)
3 /
COUNT(*)
----------
0
SQL> update range_sales_exchange
2 set time_id = sysdate
3 /
100 rows updated.
SQL> commit
2 /
Commit complete.
SQL>
SQL> -- session1
SQL> print v_cur
PROD_ID CUST_ID TIME_ID C PROMO_ID QUANTITY_SOLD AMOUNT_SOLD
---------- ---------- --------- - ---------- ------------- -----------
1 1 01-FEB-00 A 1 1 1
2 1 01-FEB-00 A 1 1 1
3 1 01-FEB-00 A 1 1 1
4 1 01-FEB-00 A 1 1 1
5 1 01-FEB-00 A 1 1 1
.
.
.
99 1 01-FEB-00 A 1 1 1
PROD_ID CUST_ID TIME_ID C PROMO_ID QUANTITY_SOLD AMOUNT_SOLD
---------- ---------- --------- - ---------- ------------- -----------
100 1 01-FEB-00 A 1 1 1
100 rows selected.
SQL>
SY.
P.S. Таблица range_sales из доки.