Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to Swap Two Tables?

Re: How to Swap Two Tables?

From: mcstock <mcstock_at_enquery.com>
Date: Thu, 23 Oct 2003 17:01:12 -0400
Message-ID: <1PydnQLK_egr3AWiRVn-uw@comcast.com>


very good solution -- if they're in the same schema

otherwise (with the appropriate permissions,

  1. create table userX.t3 as select * from user1.t1;
  2. alter table user1.t1 disable primary key;
  3. truncate table user1.t1;
  4. insert into user1.t1 select * from user2.t2;
  5. alter table user2.t2 disable primary key;
  6. truncate table user2.t2
  7. insert into user.2t2 select * From userX.t3;
  8. drop table userX.t3;
  9. alter table user1.t1 enable primary key;
  10. enable all foreign keys that reference the t1 table (this information can be obtained from DBA_CONSTRAINTS or perhaps from USER_CONSTRAINTS
  11. alter table user2.t2 enable primary key;
  12. enable all foreign keys that reference the t1 table (this information can be obtained from DBA_CONSTRAINTS or perhaps from

Mark C. Stock
www.enquery.com
(888) 512-2048

"nobody" <nobody_at_nowhere.com> wrote in message news:7mUlb.253604$ko%.218644_at_news04.bloor.is.net.cable.rogers.com...
> tables t1 t2
> rename t1 to t3;
> rename t2 to t1;
> rename t3 to t2;
>
> "RK" <rekaben_at_yahoo.com> wrote in message
> news:239f1935.0310230807.5a9ccbc1_at_posting.google.com...
> > Assuming space if not a problem, how can I exchange two table content
> > (two table in same definition and structure) using SQL?
> >
> > RK
>
>
Received on Thu Oct 23 2003 - 16:01:12 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US