Move schema to a diff.tablespace

Dear all,
How can I move a particular shcema objects or the complete schema from his default tablespace to other tablespace ?
Kai

Kai,
Here are some ways you can move schema from its default tablespace to other tablespace.
Using anonymous pl/sql block or sql script;
DECLARE
   CURSOR mcur
   IS
      SELECT   table_name FROM user_tables;
   v_sql                        VARCHAR2 (100);
   c_tablespace_name CONSTANT   VARCHAR2 (30) := 'MY_NEW_TS_NAME';
BEGIN
   FOR x IN mcur
   LOOP
      v_sql :=
            'alter table '
         || x.table_name
         || ' move tablespace '
         || c_tablespace_name;
      DBMS_OUTPUT.put_line (v_sql);
   -- execute immediate v_sql :
   END LOOP;
END;*2nd Method*;
Using conventional export and import
exp username/password file=myuserexport.dmp log=myuserexport.log
Before importing
1. drop all the objects from user (except roles and db-link).
2. Setup a new default tablespace and revoke unlimited tablespace from the user and set quota 0 on old tablespace.
3. You can also drop entire user and recreate one with new default tablespace
imp username/password file=myuserexport.dmp log=myuserexport.log*3rd Method: (if using 10g), you can make use of datapump (remap tablespace)*
http://www.oracle-base.com/articles/10g/OracleDataPump10g.php
Regards
Edited by: OrionNet on Mar 11, 2009 12:27 AM

Similar Messages

  • Move schema to another tablespace

    I want to move one schema and all objects own by particular schema to it's own tablespace (new_tablespace).
    will command provided below move all existing schema objects to new tablespace or just new objects?
    alter user default tablespace new_tablespace;

    mishomor wrote:
    I know it's long time since I posted this but I finally had a change to implement it.
    Thing is, if I execute command on one-by-one basis it works fine, but if I try block you guys posted it doesn't work. It ends with error:
    Error starting at line 1 in command:
    begin
    for tbl in (select table_name from all_tables where owner = 'FLOWS_020000') loop
    execute immediate 'alter table ' || tbl.table_name || ' move tablespace flows';are you executing this as the owner of 'tbl_name'?
    end loop;
    end;
    Error report:
    ORA-00942: table or view does not exist
    ORA-06512: at line 3
    00942. 00000 - "table or view does not exist"
    Cause:
    Action:
    begin
    for tbl in (select table_name from all_tables where owner = 'FLOWS_020000') loop
    execute immediate 'alter table ' || tbl.table_name || ' move tablespace flows';
    end loop;
    end;
    output of
    select table_name from all_tables where owner = 'FLOWS_020000';
    brings bunch of tables!!
    If I just run ...
    alter table FLOWS_020000.whatever_table move tablespace flows;
    alter index FLOWS_020000.whatever_index rebuild tablespace flows;
    ... it works fine.
    Because here you specifically qualified the table name with the owner. In your procedure above, you did not do that, so 'whatever_table' was assumed to be owned by whoever was executing the procedure.
    I am using SqlDeveloper 1.5.4

  • Move schema to anothe tablespace

    Hi
    During installation of one Oracle application , this has created "WIRELESS" schema in system tablespace. "WIRELESS" schema consis of table/index/LOB Objects. Now I want to migrate entire wireless schema to xx_tablespace. kindly suggest me the ways to do this.
    Thanks
    Krishna

    Have you read the documentation? Every single option for expdp and impdp is documented http://docs.oracle.com/cd/E11882_01/server.112/e22490/toc.htm
    As Osama suggested:
    a). Create a new schema with the default tablespace set to the tablespace to where you want to move the objects
    b). expdp the old schema
    c). impdp the using fromuser/touser to put the objects into the new schema
    d). Drop the old schema
    e). Rename the new schema to the old schema
    Another alternative that wouldn't need expdp/impdp and a temporary new schema would be to use alter table move and alter index rebuild to move the tables/indexes directly. If you have partitioned tables, you'd need to account for that. You can do the same in online mode using DBMS_REDEFINITION
    Which option you pick probably depends on a few things:
    a). Downtime requirements - DBMS_REDEFNITION can possibly do the reorg with zero downtime.
    b). Size of objects in the schema and whether you have enough space for the extra expdp file
    John

  • Import schema to a different tablespace

    hi,
    I've exported my instance:
    EXP SYSTEM/MANAGER@OLDINSTANCE FULL=Y FILE=C:\EXP_FILE.DMP LOG=C:\ERROR_EXP.LOG
    after I've created new tablespace and new user:
    CREATE TABLESPACE MAX DATAFILE 'c:\MAX01.dbf' SIZE 3800M REUSE DEFAULT STORAGE
    (INITIAL 10240 NEXT 10240 MINEXTENTS 1 MAXEXTENTS 256 PCTINCREASE 0) ONLINE;
    CREATE USER MAX IDENTIFIED BY MAX DEFAULT TABLESPACE MAX TEMPORARY TABLESPACE TEMP;
    finally I've imported tom's objects in MAX:
    IMP SYSTEM/MANAGER@NEWINSTANCE FROMUSER=TOM TOUSER=MAX FILE=C:\EXP_FILE.DMP LOG=C:\ERROR_IMP.log
    but in some tables I get these errors:
    IMP-00017: following statement failed with ORACLE error 1658:
    "CREATE TABLE "AREA" ("OFL" VARCHAR2(4), "OBL" VARCHAR2(32), "OSITE" V"
    "ARCHAR2(32), "OLS" VARCHAR2(32), "OAREA" NUMBER, "DV_ID" VARCHAR2(32), "DP_"
    "ID" VARCHAR2(32), "ODISMESSO" VARCHAR2(2), "OTYPE" VARCHAR2(64), "OCAT" VAR"
    "CHAR2(64), "OOCCUP" NUMBER, "SFL" VARCHAR2(32), "SBL" VARCHAR2(32), "SSITE""
    " VARCHAR2(32), "PRORATE" VARCHAR2(8), "STYPE" VARCHAR2(64), "SCAT" VARCHAR2"
    "(64), "SAREA" NUMBER, "SOCCUP" NUMBER, "AREA_SERV" NUMBER) PCTFREE 10 PCTU"
    "SED 40 INITRANS 1 MAXTRANS 255 LOGGING STORAGE(INITIAL 314572800 NEXT 52428"
    "800 MINEXTENTS 1 MAXEXTENTS 1000 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS "
    "1 BUFFER_POOL DEFAULT) TABLESPACE "TOM""
    IMP-00003: ORACLE error 1658 encountered
    ORA-01658: unable to create INITIAL extent for segment in tablespace TOM
    In new instance there are 2 tablespaces (TOM, MAX)
    I tried 2 solution:
    1) I've taken the tablespace TOM offline in the new instance, but when I import fromuser=TOM touser=MAX.............
    I get error because not exist tablespace TOM
    2)I removed MAX's quota on the TOM tablespace in the new instance.
    ALTER USER MAX QUOTA unlimited ON TOM;
    but when I import I get alway the same error:
    ORA-01658: unable to create INITIAL extent for segment in tablespace TOM
    I know That I must encrease tablespace TOM for avoid this error, but I must create 6 new users in 6 different tablespaces and I'd to increase tablespace TOM too much (how many GB?).
    how can I import schema to a different tablespace?
    Thanks
    Raf

    I don't understand why you cannot import TOM's scheme
    to new instance, because you say that you' ve TOM
    tablespace in the database.
    Check size of it, may be you need to increase size or
    you can TOM tablespace set autoextended.
    Also, you can set MAX tablespace is default in new database and set TOM tablespace is readonly.
    Then import cannot create object in TOM tablespace
    and create this in MAX tablespace.
    Best regards, Victor

  • Move index to a different tablespace using dbms_redefinition?

    Hi all, I am trying to move indexes to new tablespaces. Can I use oracle built-in package DBMS_REDEFINITION for this? As far as I know dbms_redefinitoin only works for tables rebuilt online? I am running 10.2.0.5 on linux red hat, and the index sizes from 100MB to 10gb. Thank you in advance all.

    Since one can seamlessly move an index from one tablespace to another by simply doing:
    SQL>  alter index <index_name> rebuild tablespace <tablespace_name>;even considering DBMS_REDEFINITION for this makes no sense at all.
    If your boss has any further questions, show him the Oracle documentation:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_redefi.htm
    Quote from that page:
    "The DBMS_REDEFINITION package provides an interface to perform an *online redefinition of tables*."
    (Emphasis added by me.)
    Hope that helps,
    -Mark

  • CREATE TABLE for another OWNER/SCHEMA and in another TABLESPACE?

    I am logged in a SYSTEM user. Now I want to create a table aaa. The owner of this table should not be SYSTEM but user KARL. and the TABLESPACE should not be SYSTEM but the (existing) TABLESPACE tttt.
    As far as I know I can achieve this by issuing the following command:
    CREATE TABLE KARL.aaa ( a INTEGER, .......) TABLESPACE tttt;
    Regarding the TABLESPACE parameter I am not sure. Is it possible to allocate a TABLE for User Karl in a TABLESPACE which is not assigned to him?
    Furthermore I have an additional problem.
    I have a script with hundreds of CREATE TABLE + ALTER TABLE + CREATE INDEX DDL statements.
    All of them are not prepended with Schema/Owner and an TABLESPACE clause.
    Can I put somehow one single instruction at the top of the script which telles Oracle
    to use
    - OWNER Karl as Schema/Owner for all subsequent DDL stements
    - TABLESPACE tttt as TABLESPACE for all subsequent DDL stements
    In MYsql there is a "use <database>" statement. Is there soemthing similar for Oracle?
    Thank you
    Peter

    Yes... you can do that. Take for example a user A who has a secret password that you don't wish to give out... like an application schema. User B needs to make tables/objects in schema A and you want to track what user B is doing. First setup Oracles Fine Grained Auditing and then grant "connect through" from user A to user B as follows:
    SQL> create user b identified by abc123
      2    quota unlimited on users;
    User created.
    SQL> grant create session to b;
    SQL> create user a identified by abc123
      2    quota unlimited on users;
    User created.
    SQL> grant create table
      2      , create session
      3     to a;
    Grant succeeded.
    SQL> alter user a grant connect through b;
    User altered.
    SQL> connect b[a]/abc123@a486
    Connected.
    SQL> show user
    USER is "A"
    SQL> create table a.my_proxy_table
      2  ( c1 number
      3  , c2 varchar2(50)
      4  , c3 date
      5  );
    Table created.-----
    See that I connected using the "username[proxyuser]" syntax. Also notice that user B is by proxy user A, illustrated by my "show user" command. The connect through can be granted/revoked as needed without divulging A's password to B. In addition, your audit tables or xml logs will track the fact that user B created table a.my_proxy_table.
    Hope this helps,
    John

  • Move indexes to a different tablespace

    What is the best and easiest method to move all indexes/constraints to a different tablespace. I have 2 tablespaces one for data and the other for the indexes. At present, I have all data and indexes all in one tablespace. I would like to separate the indexes to another tablespace(which is reserved specifically for the indexes)
    Thanks

    You do not move constraints.
    You can use the command:
    ALTER INDEX index_name REBUILD TABLESPACE new_tablespace;

  • How can I import schema to a different tablespace in a new database?

    Hi,
    I want to transport a schema "abc", which is on 'USERS" tablespace in the old database, to a new database using Data Pump. But on the new server, I want it on a different tablespace, say "TEST". How can I do that? I tried the following but it does not work:
    1. Create a user "abc" on new database, assign "TEST" as its default tablespace;
    2. use impdp to import the dmp file;
    I found that on the new server, the imported tables are still on the "USERS" tablespace.
    Can anyone tell me how to do it? thanks a lot.

    Use the REMAP_TABLESPACE option:
    REMAP_TABLESPACE = source_tablespace:target_tablespace
    Rick

  • Schema-aware XML Diff utility

    Is there a XML Diff utility/API that is schema aware? i.e. can determine that <foo bar="true"/> is the same as <foo/> if the schema says that the default value for the optional bar attribute is "true".
    As far as I can see, oracle.xml.XMLDiff has no such feature.
    Vijay

    Most XML diff APIs are not schema aware. XML document differences implies differences in XML elements and attributes, not a validation of the XML documents with a schema.
    http://www.devx.com/Java/Article/30943

  • Move Schema to Prod

    Hi All,
    I am not a DBA, but recently I was assigned these duties.
    My question is that we have a schema in Dev, Its has been tested now I have to move this to Prod.
    I have created some scripts using Toad (database\export\tables, views etc).
    Can use these scripts for import also?
    Is there any other way to move a schema from Dev to Prod or visa verse?
    There is one more questions, using toad I can view DBlinks but I cannot view them in Dev. I get this error ORA-00942: table or view does not exist.
    any suggestion welcome
    Habeeb

    Hi Everyone,
    I am back and I have created a new Schema...
    But I did a lot of mistakes, I created the sequences, procedures and functions logged in as SYSTEM.
    the sequences I dropped them as they all had the schema name used in the name of sequence.
    example: if schema name "HABTEST" then
    seq name "SEQ_SCANLOG_HABTEST"
    that's done.
    But for Procedure and Fuction we had the same rule so I logged in as 'SYSTEM'
    and droped all procedure's and function with name like 'HABTEST'.
    But now there are some that don't have the schema name in the procedure name...
    example:
    SQL> SELECT owner, object_name, object_Type
    2 from all_objects
    3 where object_name = upper('batche_rcv_today');
    OWNER OBJECT_NAME OBJECT_TYPE
    SYSTEM BATCHES_RCVD_TODAY FUNCTION
    HABTEST BATCHES_RCVD_TODAY FUNCTION
    Now in this case if I execute the command
    drop procedure BATCHES_RCVD_TODAY will it drop the only procedure in the system OWNER as I am logged in as SYSTEM, Technically It should and the other in HABTEST should remain intact...
    I am right..??
    Habeeb

  • After move tables and index another tablespace, indexes got unusable?

    Hi,
    I moved table and indexes another tablespace. After move many indexes got unusable state. I couldn't understand thiis?
    How can I make them again usable?
    regards and thanks?

    hi,
    check this query below
    create table test (id number(10));
    create table succeeded.
    insert into test values (10);
    1 rows inserted
    commit;
    create index test_indx on test(id);
    select index_name, status from user_indexes
    where table_name = 'TEST';
    INDEX_NAME STATUS
    TEST_INDX VALID
    alter table test move tablespace users;
    select index_name, status from dba_indexes
    where table_name = 'TEST';
    INDEX_NAME STATUS
    TEST_INDX UNUSABLE
    rebuliding index
    alter index test_indx rebuild
    alter index test_indx succeeded.
    then check
    select index_name, status from user_indexes
    where table_name = 'TEST';
    INDEX_NAME STATUS
    TEST_INDX VALID

  • SOS!! How to export a schema while the SYSAUX tablespace is offline?

    Hello,
    the SYSAUX for one of our productive database became corrupted and I had to take it offline in order to open the database. There is no way to recover it since there are missing archive logs from the sequence.
    So I need to export a database schema which holds all the productive tables/indexes (there are no procedure, functions, packages, triggers,etc - just tables, constraints and indexes).
    When I try to export the schema, I get the following error:
    Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    Export done in UTF8 character set and UTF8 NCHAR character set
    . exporting pre-schema procedural objects and actions
    . exporting foreign function library names for user CMS31_ARMENTEL_SITE_N
    . exporting PUBLIC type synonyms
    . exporting private type synonyms
    . exporting object type definitions for user CMS31_ARMENTEL_SITE_N
    About to export CMS31_ARMENTEL_SITE_N's objects ...
    . exporting database links
    . exporting sequence numbers
    . exporting cluster definitions
    EXP-00056: ORACLE error 376 encountered
    ORA-00376: file 3 cannot be read at this time
    ORA-01110: data file 3: '/opt/data1/oradata/UTF8/sysaux01.dbf'
    ORA-06512: at "SYS.DBMS_METADATA", line 1511
    ORA-06512: at "SYS.DBMS_METADATA", line 1548
    ORA-06512: at "SYS.DBMS_METADATA", line 1864
    ORA-06512: at "SYS.DBMS_METADATA", line 3707
    ORA-06512: at "SYS.DBMS_METADATA", line 3689
    ORA-06512: at line 1
    EXP-00000: Export terminated unsuccessfully
    I've tried direct export, data pump (expdp) but with the same unsucessfull results.
    Is there any way to use the export or expdp utility to get the actual data from a specific schema ?
    Many thanks

    Hello Harry and many thanks for your reply.
    EXCLUDE is an option of expdp not exp. So I used expdp and get the following error:
    expdp impexp/blabla dumpfile=SITE_N.dmp schemas=SITE_N exclude=CLUSTER:SITE_N
    Export: Release 10.1.0.2.0 - Production on Tuesday, 29 January, 2008 20:56
    Copyright (c) 2003, Oracle. All rights reserved.
    Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    ORA-31626: job does not exist
    ORA-31638: cannot attach to job SYS_EXPORT_SCHEMA_05 for user IMPEXP
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
    ORA-06512: at "SYS.KUPV$FT_INT", line 377
    ORA-39077: unable to subscribe agent KUPC$A_1_20080129205606 to queue "KUPC$C_1_20080129205606"
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
    ORA-06512: at "SYS.KUPC$QUE_INT", line 248
    ORA-25448: rule SYS.KUPC$C_1_20080129205606$227 has errors
    ORA-00376: file 3 cannot be read at this time
    ORA-01110: data file 3: '/opt/data1/oradata/UTF8/sysaux01.dbf'
    Different error (since now I use expdp) but for the same reason (SYSAUX is offline)
    Regards
    Argyris

  • Tablespace droped and objects moved

    hi
    I have
    1) move tablespace(A) objects ( Tables and indexes ) to differant tablespace (B).
    2) Drop tablespace(A) .
    3) Recreate tablespace(A)
    4) Again move objects(Tables and indexes) to tablesapce A.
    does it work same as export and import or it will corrept my tablespace(A).
    Please suggest.
    Edited by: Anil1 T on Mar 1, 2012 1:35 AM
    version 9.2.0.7 with DWH database , i am planning to do that , please suggest what would be the effact

    Hi;
    Please see:
    Moving objects from one tablespace to other tablespace
    how to move schema objects from one tablespace to another tablespace?????
    Regard
    Helios

  • Moving partitions

    Hi guys.
    Based on a new request, i need to create a script to backup and delete old data from our huge and many tables, which are growing a lot every day.
    Backups to tapes will be done by db admins, so my sript should just move old partitions. I was thinking about to create extra tablespace where i will be moving those old partitions and data from this tablespace will be put on tapes and deleted later on. All tables are partitioned by time.
    Could you please advise me how should i do so ? What is the best way to move huge partitions to diff. tablespace. Script will be run one per day
    Thanks a lot

    dusoo wrote:
    No reply, so i guess there is no better way in ora10 for moving partitions between two partitioned tables ?
    I still need to move it from source part. table to a non-part. table, and from there to the final part. tableYou need to understand that this two-way operation is not expensive if you simply want to bring a partition from one partitioned table to another one which is having the same partition boundary definitions. You're simply performing two exchange partition operations (partition<->unpartitioned, unpartitioned<->partitioned) which optimally can be pure data dictionary updates (there are exceptions to this rule if you e.g. have enabled unique constraints then the validation can not be skipped (WITHOUT VALIDATION clause)) and don't involve any actual data movement.
    The expensive part in your particular case is the actual data movement to a different tablespace. The question is do you need to move the segments to a separate tablespace? Probably yes if you want to use a backup method based on binary copies of datafiles and tablespaces like RMAN. A logical export of the tables e.g. using datapump could be restricted to tables and/or partitions so you wouldn't need to perform an actual data movement.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • How to move tables from one user to another user in same tablespace;

    How can i move the tables & data starting with TIS_ from USER1 schema to this new schema?
    By below query i created new schema:-
    create user TEST identified by TEST12 default tablespace DMGTS;
    Both the USER/Schema are in same tablespace.
    It is ORACLE9i.
    Please reply....

    User1.A
    User2.B
    1) Create patitioned tables based on User1.A, ex. User1.P
    2) ALTER TABLE User1.P
    EXCHANGE PARTITION YOUR_PART_NAME TABLE User1.A
    WITHOUT VALIDATION; -- After this all your data from User1.A will be moved to User1.P(YOUR_PART_NAME)
    3) ALTER TABLE User1.P
    EXCHANGE PARTITION YOUR_PART_NAME TABLE User2.B
    WITHOUT VALIDATION; -- After this all your data from User1.P(YOUR_PART_NAME) will be moved to User2.B
    All data moving will take about 2-3 sec.
    Regards,

Maybe you are looking for

  • Can't see my events in iCal

    Hi all, maybe someone can help me with the following scenario. I synchronize my Sony Ericsson cellphone via iSync to iCal. Afer installing new software on my cellphone, all data got lost (of course). As I wanted to synchronize my data to the cellphon

  • File-to-File Scenario: Parsing issue

    Hey experts, I had to work with idoc-to-file or file-to-file several times, and i noticed that sometimes if one data to map to the file was incomplete it caused several errors mapping, there's any way to fix that? Let me explain with an example: XML

  • 2 questions on what's wrong and how to fix them

    I have been using sueface rt for quite some time now and recently, I've started facing issues with some areas and have been unable to find answers anywhere. hoping that someone will be able to help me with my problems as it is getting pretty irritati

  • I have a white/grey screen and none of the suggested operations have helped, what should I do?

    I have a white/grey screen and none of the suggested options have worked - I have tried all the suggestions on Apple support

  • WBS element wise POs

    Guru can I get the name of the table which has a link between WBS element in PS to PO placed placed i.e.PO number I have tried to find it in se11 but could not be found out. Atul