Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Query Help : Add partition name Dynamically from existing table

Ricky007Aug 6 2021

Dear Experts
12.1.0.2.0
Please help to add partition dynamically from tran_log table to tran_hist table.
SELECT partition_name PNAME, high_value
from USER_TAB_PARTITIONS
WHERE table_name = 'TRAN_LOG';
image.png
ALTER TABLE TRAN_HIST ADD PARTITION P_230521 VALUES LESS THAN (TO_DATE('2021-05-23 00:00:00', 'YYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'));
ALTER TABLE TRAN_HIST ADD PARTITION P_260521 VALUES LESS THAN (TO_DATE('2021-05-26 00:00:00', 'YYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'));
ALTER TABLE TRAN_HIST ADD PARTITION P_270521 VALUES LESS THAN (TO_DATE('2021-05-27 00:00:00', 'YYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'));

Please help me to add partition name dynamically for the respective partition in tran_hist table from tran_log table.

Expected Result
SELECT partition_name PNAME, high_value
from USER_TAB_PARTITIONS
WHERE table_name = 'TRAN_HIST';

image.png

Comments
Post Details
Added on Aug 6 2021
1 comment
622 views