Forum Stats

  • 3,768,999 Users
  • 2,252,895 Discussions
  • 7,874,835 Comments

Discussions

Rename Table (Swap)

Bahram Orujov
Bahram Orujov Member Posts: 43 Red Ribbon
edited Feb 23, 2018 11:37AM in General Database Discussions

Hi. I have two tablespacece and two table as you see. Table A is in test1 tablespace and table B is in test2 tablespace. I created table B using:

create table b as select * from A;

After that I want to rename Table B to Table A. But I don't want to lost my indexes, treiggers and all kind kind of object of old Table A.

I want to inherit all "objects" of Table A(old table A) to Table B (new table b).

Untitled.png

Tagged:
Marcus RangelBahram Orujov

Best Answer

  • Bahram Orujov
    Bahram Orujov Member Posts: 43 Red Ribbon
    edited Feb 22, 2018 8:28AM Accepted Answer

    I found new way to solve this. So I created a copy of table  A as Table B in the tablespace 2 (create table b tablespace test2 as select * from a). After that I truncated Table A and moved it to tablespace test2. And I insert data back from Table B to Table A. (insert into A select * from B). That is all.

    Thank your for your help.

«1

Answers

This discussion has been closed.