Skip to content

Instantly share code, notes, and snippets.

@kleontev
Created June 1, 2022 04:47
Show Gist options
  • Save kleontev/5aa15ae089a352c9c4b94cfcdbd45dfb to your computer and use it in GitHub Desktop.
Save kleontev/5aa15ae089a352c9c4b94cfcdbd45dfb to your computer and use it in GitHub Desktop.
does alter table exchange partition update LAST_DDL_TIME? (yes)
SQL>
SQL> alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS'
2 /
Session altered.
SQL>
SQL> drop table test_last_ddl purge
2 /
Table dropped.
SQL>
SQL> drop table test_exch_part purge
2 /
Table dropped.
SQL>
SQL> create table test_last_ddl (part_key date, id int, val int)
2 partition by range (part_key)
3 interval (interval '1' day) (
4 partition p_dummy values less than (date '2020-1-1')
5 )
6 /
Table created.
SQL>
SQL> select object_name, subobject_name, last_ddl_time from user_objects where object_name = 'TEST_LAST_DDL'
2 /
OBJECT_NAME SUBOBJECT_NAME LAST_DDL_TIME
------------------------------ ------------------------------ -------------------
TEST_LAST_DDL 2022-06-01 04:45:39
TEST_LAST_DDL P_DUMMY 2022-06-01 04:45:39
SQL>
SQL> exec dbms_lock.sleep(1)
PL/SQL procedure successfully completed.
SQL>
SQL> alter table test_last_ddl move partition p_dummy
2 /
Table altered.
SQL>
SQL> select object_name, subobject_name, last_ddl_time from user_objects where object_name = 'TEST_LAST_DDL'
2 /
OBJECT_NAME SUBOBJECT_NAME LAST_DDL_TIME
------------------------------ ------------------------------ -------------------
TEST_LAST_DDL 2022-06-01 04:45:40
TEST_LAST_DDL P_DUMMY 2022-06-01 04:45:40
SQL>
SQL> create table test_exch_part as select * from test_last_ddl
2 /
Table created.
SQL>
SQL> exec dbms_lock.sleep(1)
PL/SQL procedure successfully completed.
SQL>
SQL> alter table test_last_ddl exchange partition p_dummy with table test_exch_part
2 /
Table altered.
SQL>
SQL> select object_name, subobject_name, last_ddl_time from user_objects where object_name = 'TEST_LAST_DDL'
2 /
OBJECT_NAME SUBOBJECT_NAME LAST_DDL_TIME
------------------------------ ------------------------------ -------------------
TEST_LAST_DDL 2022-06-01 04:45:41
TEST_LAST_DDL P_DUMMY 2022-06-01 04:45:41
col object_name for a30
col subobject_name for a30
set lines 200
set echo on
cl scr
alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS'
/
drop table test_last_ddl purge
/
drop table test_exch_part purge
/
create table test_last_ddl (part_key date, id int, val int)
partition by range (part_key)
interval (interval '1' day) (
partition p_dummy values less than (date '2020-1-1')
)
/
select object_name, subobject_name, last_ddl_time from user_objects where object_name = 'TEST_LAST_DDL'
/
exec dbms_lock.sleep(1)
alter table test_last_ddl move partition p_dummy
/
select object_name, subobject_name, last_ddl_time from user_objects where object_name = 'TEST_LAST_DDL'
/
create table test_exch_part as select * from test_last_ddl
/
exec dbms_lock.sleep(1)
alter table test_last_ddl exchange partition p_dummy with table test_exch_part
/
select object_name, subobject_name, last_ddl_time from user_objects where object_name = 'TEST_LAST_DDL'
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment