SQL or PL/SQL which every is faster and more convienient
Main Topics
Browse All TopicsI have two schema’s and want to copy some of the tables and the data in the tables from schema A to schema B and but when I take over the tables I want to change the tablespace and rename the table, I want to create a script for this so that I can run it many time could I have some help to create the script.
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
A PL/SQL procedure would be pretty easy.
The owner of the procedure needs these 2 grants:
GRANT GRANT ANY OBJECT PRIVILEGE TO <own>;
GRANT CREATE ANY TABLE TO <own>;
These are required because PL/SQL does not understand privileges granted through roles.
As a catch, the procedure cannot be created under the new owner as you cannot grant privileges to yourself.
Though not "exactly" what you were looking for, I'd try using this:
COPY FROM schema_a/your_password@DB -
TO schema_b/your_password@DB -
CREATE new_emp_name (DEPARTMENT_ID, DEPARTMENT_NAME, CITY) -
USING SELECT department_id, depart_name, city FROM emp;
You can't specify which TABLESPACE the NEW_EMP_NAME table is created in, however, it will be created in the DEFAULT TABLESPACE of the the SCHEMA_B user...
Business Accounts
Answer for Membership
by: johnsonePosted on 2008-01-14 at 08:10:55ID: 20653981
These should be the commands you need:
As SCHEMA_A
GRANT SELECT ON <old_tab> to <schema_b>;
As SCHEMA_B
CREATE TABLE <new_tabl> TABLESPACE <new_ts> AS SELECT * FROM <schema_a>.<old_tab>;
There would be many different ways to script this, what kind of script are you looking for? SQL, PL/SQL, Shell, Perl, etc.