Important alert: (current site time 7/15/2013 7:39:40 PM EDT)
 

article

Moving Schema's Across Tablespace's

Email
Submitted on: 2/27/2002 9:39:57 PM
By: jtanwar  
Level: Intermediate
User Rating: Unrated
Compatibility: Oracle
Views: 10692
(About the author)
 
     If you are running a Number of Schemas Under One service(Which usually) the Case is and Needs to Move all the Tables Belonging to a Particular schema’s To a new tablespace, then instead of Manually typing the Command Alter table tablename move tablespace tsname; For each Individual table , Instead use this Simple Procedure which use the DBA_TABLES Information to move All the tables Belonging to a Particular Schema From One tablespace to another Tablespace. It needs the SCHEMA NAME AND THE TABLESPACE NAME(To which all the Tables ) to be moved as Input parameters.

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
				






CREATE OR REPLACE PROCEDURE TOBJECTFROMTS (
<--[if gte mso 9]>
 
 Administrator
 Normal
 Administrator
 2
 2
 2002-08-17T07:30:00Z
 2002-08-17T07:30:00Z
 1
 PCONE
 1
 1
 9.3821
 




CREATE OR REPLACE PROCEDURE TOBJECTFROMTS (

V_Owner IN VARCHAR2,

V_NEWTS IN VARCHAR2

 

)

IS

v_table_name varchar2(100);

str_sql varchar2(200);

 

---Opening an explicit cursor to get all the users belonging to the Schema

cursor schematables(Owner varchar2) is

select TABLE_NAME from DBA_TABLES x

Where LOWER(x.OWNER) = LOWER(V_OWNER);

BEGIN

open schematables(V_owner);

loop

Fetch schematables into v_table_name ;

exit when schematables%notfound;

---DBMS_OUTPUT.put_line(' alter table '|| v_table_name || ' move tablespace psle1;');

str_sql := 'alter table '|| v_table_name || ' move tablespace' ||' ' ||'' || V_NEWTS ||'';

DBMS_OUTPUT.put_line(str_sql);

--- str_sql is the sql statement that we want to execute to move the

-- tablespaces to the New table space

execute immediate str_sql;

end loop;

close schematables;

EXCEPTION

WHEN NO_DATA_FOUND

THEN

DBMS_OUTPUT.put_line ('THERE IS NO SUCH RECORD');

--RAISE_APPLICATION_ERROR(-20045,'NO DATA FOUND');

END;

/

 


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

5/21/2002 12:42:20 PMCharlie Kirkwood

just a tip - it's better to upload the code so it's readable - the way you have it listed makes it difficult to read and/or use.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.