Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle : Swapping table names

I need to load a table with ~18M records in a daily basis, and in order to minimize the down time on the client side, we have the approach of loading a temp then swap the table names after. see process below

Table A is the orginal table, Table TMP is the temporary table

  1. load Table TMP
  2. rename Table A to Table A_V1
  3. rename Table TMP to Table A
  4. rename Table A_V1 to Table TMP
  5. truncate Table TMP in preparation for next load

Is there any other way of swapping the table names? or any other way to achieve this?

Thanks a lot.

like image 249
Ianthe Avatar asked Mar 20 '26 20:03

Ianthe


1 Answers

Use a synonym.

Firstly load into TABLEA_YYYYMMDD, recreate constraints etc.

Then,

create or replace synonym tablea for tablea_yyyymmdd

Lastly, if you want to, drop the previous tablea_yyyymmdd.

like image 61
Ben Avatar answered Mar 24 '26 01:03

Ben



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!