Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [oracle@stormking cdb12102 table]$ sqlplus /nolog @ conn.pdbm.u.sql
- SQL*Plus: Release 12.1.0.2.0 Production on Sat Jun 3 21:44:22 2017
- Copyright (c) 1982, 2014, Oracle. All rights reserved.
- Connected.
- SQL> @ change.owner.sql
- SQL> drop user olduser cascade;
- User dropped.
- SQL> drop user exchuser cascade;
- User dropped.
- SQL> drop user newuser cascade;
- User dropped.
- SQL> create user olduser identified by pw default tablespace users quota unlimited on users;
- User created.
- SQL> create table olduser.lost ( f varchar2(30), l varchar2(30) );
- Table created.
- SQL> insert into olduser.lost ( f, l ) values ( 'Sherlock', 'Holmes' );
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> alter table olduser.lost
- 2 add constraint lost_pk primary key ( f, l );
- Table altered.
- SQL>
- SQL> create user exchuser identified by pw default tablespace users quota unlimited on users
- 2 ;
- User created.
- SQL> create table exchuser.exch
- 2 partition by range ( l )
- 3 ( partition m values less than ( maxvalue ) )
- 4 as select * from olduser.lost where 1 = 0;
- Table created.
- SQL>
- SQL> alter table exchuser.exch
- 2 add constraint tbls_pk primary key ( f, l ) using index local;
- Table altered.
- SQL> alter table exchuser.exch
- 2 exchange partition m with table olduser.lost including indexes;
- Table altered.
- SQL>
- SQL> create user newuser identified by pw default tablespace users quota unlimited on users
- 2 ;
- User created.
- SQL> create table newuser.found
- 2 ( j varchar2(30), k varchar2(30) );
- Table created.
- SQL> alter table newuser.found
- 2 add constraint found_PK primary key ( j, k );
- Table altered.
- SQL> alter table exchuser.exch
- 2 exchange partition m with table newuser.found including indexes;
- Table altered.
- SQL> select j, k from newuser.found;
- J K
- ------------------------------ ------------------------------
- Sherlock Holmes
- SQL>
- SQL> select owner, index_name, table_owner, table_name, num_rows, status
- 2 from dba_indexes where table_owner = 'NEWUSER' and table_name = 'FOUND';
- OWNER INDEX_NAME TABLE_OWNER TABLE_NAME NUM_ROWS STATUS
- ------------------------------ ------------------------------ ------------------------------ ------------------------------ ---------- --------
- NEWUSER FOUND_PK NEWUSER FOUND 1 VALID
- SQL>
- SQL> quit
- Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
- With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
- and Real Application Testing options
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement