要将用户a下的表t移动到用户b下,如果数据量比较大,可以采用分区交换的方法,在很短的时间内实现数据从用户a移动到用户b下:
SQL> grant resource ,connect to a identified by a;
Grant succeeded.
SQL> grant resource ,connect to b identified by b;
Grant succeeded.
SQL> create table a.t(a number) tablespace users;
Table created.
SQL> insert into a.t values(1);
1 row created.
SQL> commit;
Commit complete.
SQL> create table b.t(a number) partition by hash(a) (partition p1);
Table created.
SQL> select * from a.t;
A
----------
1
SQL> select * from b.t;
no rows selected
SQL> alter table b.t exchange partition p1 with table a.t;
Table altered.
SQL> select * from a.t;
no rows selected
SQL> select * from b.t;
A
----------
1
SQL> grant resource ,connect to a identified by a;
Grant succeeded.
SQL> grant resource ,connect to b identified by b;
Grant succeeded.
SQL> create table a.t(a number) tablespace users;
Table created.
SQL> insert into a.t values(1);
1 row created.
SQL> commit;
Commit complete.
SQL> create table b.t(a number) partition by hash(a) (partition p1);
Table created.
SQL> select * from a.t;
A
----------
1
SQL> select * from b.t;
no rows selected
SQL> alter table b.t exchange partition p1 with table a.t;
Table altered.
SQL> select * from a.t;
no rows selected
SQL> select * from b.t;
A
----------
1
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10972173/viewspace-1081238/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10972173/viewspace-1081238/