Rearrange tables in the tablespace

Hello

I have 5000 table 10 tablespace and 4000 index in tablespace 8
I have to reorganize all of these existing tables to a single tablespace and all indexes in a single space.
Could you please suggest how this can be done?


Thank you
KSG

Hello

I should do a dump of the statements:

spool table_move.sql
select 'alter table '||owner||'.'||table_name||' move;' from all_tables
where owner in ('owner1','owner2')
/
spool off

After that, you can run table_move.sql under SYSTEM.

For indexes, the code will be:

spool index_move.sql
select 'alter index '||owner||'.'||index_name||' rebuild tablespace new_tablespace;' from all_indexes
where owner in ('owner1','owner2')
/
spool off

If it is only a single schema, you can also query user_tables and user_indexes.

Hope this will help.

Herald tiomela
Superconsult.nl

Tags: Database

Similar Questions

  • What table shows the tablespace in read-only mode or read / write.

    Hi all

    Can someonoe help me find which table shows if a tablespace is read-write or read-only mode.

    Thank you
    Naveen

    DBA_TABLESPACES - STATUS column.

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14237/statviews_4157.htm#i1627812

  • Specify the tablespace for table main expdp?

    Is it possible to specify what the main table tablespace will be created in an expdp job?

    I'm carrying the default tablespace for the user who runs expdp and obviously expdp cannot create the main table because the tablespace is read only for transport. I am looking for a way to specify a different tablespace for the main table without changing the user's default tablespace. Such a thing exists in 10g or 11g? TIA

    Chuck1958 wrote:
    Is it possible to specify what the main table tablespace will be created in an expdp job?

    I'm carrying the default tablespace for the user who runs expdp and obviously expdp cannot create the main table because the tablespace is read only for transport. I am looking for a way to specify a different tablespace for the main table without changing the user's default tablespace. Such a thing exists in 10g or 11g? TIA

    Chuck1958,

    I don't know that such a setting Exit (or not)... On the other hand, here's another way:

    You can create a new user, give him required privileges and, on the other hand, starts the datapump export by this new user using the parameter "schema".

    Best regards

    Gokhan Atil

    -------------------------------------------------------
    If you answer this question, please mark appropriate as correct/useful messages and the thread as closed. Thank you

  • Cannot delete the tablespace

    Oracle 10.24
    64 bit SPARC Solaris 10.5

    I am trying to drop a tablespace to resize my original tablespace, I created, but get the following error:
    SQL > drop tablespace backup_ts including content and files of data cascade constraints;
    Drop tablespace backup_ts including the content cascade constraints and data files
    *
    ERROR on line 1:
    ORA-00604: an error has occurred at the SQL level 1 recursive
    ORA-02429: cannot delete the index used for the application of the unique/primary key
    I also delete all tables in the tablespace (backup_ts) and always error.

    Yes... These are clues... (which must be deleted or rebuilt to a different tablespace)

  • East - the usual/recommended that users have TABLEs in the spaces of multiple tables?

    As I discovered new TABLEs of users created in spaces of multiple tables for example
    SYSTEM and USERS. In other words some tables is implemented other SYSTEM in USERSs.

    Is - this normal/recommended?

    Prevent the creation of TABLEs in the TABLESPACE "SYSTEM"?

    Suppose a user bulletins 'karl' CREATE TABLE command without specifying the target TABLESPACE.

    What determines in what TABLESPACE this TABLE is created?

    Peter

    A user can create its tables in different tablespace when there quota on special tables,

    If the default tablespace is not given while creating the table then default tablespace for the user schema will be used.

    To restrict the use of the SYSTEM tablespace, use the command below

    SQL > alter user scott quota 0 on system;

    Modified user.

  • Move the table in same tablespace is not reorganize the data

    Hello.

    I am facing a problem that I have not used to have.  First of all, a description of our envorinnement:

    We have a few large tables partitioned and performance optimization, our ETLs use bluk, add notes, parallelism and so on.  This create several holes of unused space in tablespaces/data files as well a kind of leak of space on our drives.

    A complete correction would re-create the tablespaces move everything is of opposes another.  It would be impratical, because there are about 15 who are top of 100 GB; the time and effort to recreate everything is not affordable for the Business.

    Instead, we have a single proc that comes to calculate the actual amount of used space (converted to blocks) and makes a move of all objects above this block_id.  Just after this operation, there is a dynamic shrink based on the new HWM (given that the objects have been moved) on the data file freeing disk space.  As we have a datafile by tablespace and a tablespace by schema, we would like to keep this body, if we make a single movement for objects, like 'ALTER TABLE' | owner: '. ' || nom_segment | "MOVE; "(the complete query works with all types of data such as partitions of table objects, the index partitions and the subpartions).  This will move the object in the same space for the first freespace on the tables and free up space at the end of the file to shrink.  In theory.

    This unique proc used to work properly.  In a 650 GB GB 530 tablespace in use moving about 20 that Go (the amount of data beyond the HWM 530 GB) is simpler than to create a new file/TBS and the displacement of 20 GB is faster than Go 530.

    But suddenly things changed when some TBS refused to be narrowed.  What I found out: the command move doesn't fail, it works very well and Oracle really moves the object.  But for reasons that I don't know, he's not moving it at the beginning of the file, it keeps the object at the end.  So the da calculates the new HWM, but because some objects that were in the tail of the queue, the shrink is done with a very high HWM, if no real space is reclaimed.

    So, the main question: How does the ALTER TABLE FOO MOVE really works?  I thought that it would be always to move the object to the beginning of the file thus reorganize, but I analyzed the last objects that gave me this problem (block_id before and after the move, compared to block_ids empty and everything) and actually, I see that they were moved at the end of the file, although there is enough space to accommodate initially.

    Okay, I think I found the problem.  Before that I just pulled the script as posted, but then I had the good idea to improve its performance with parallelism, so I added:

    ALTER SESSION FORCE PARALLEL QUERY 16 PARALLELS;

    ALTER SESSION FORCE PARALLEL DDL PARALLEL 16;

    ALTER SESSION FORCE PARALLEL DML PARALLEL 16;

    Returning to prallel not running, that I could reuse the freespace on the beginning of the file, and then narrow it down.

    Obviously, each writing data in parallel mode reuse freespace, I just forgot that a TABLE ALTER MOVE is also a data write operation.  I fell a bit ridiculous, caught in the same trap that I was trying hard.

    Thank you all for the comments and advice.

  • How to check the value of the space of the tablespaces and tables when errors occur?

    Hi Experts,

    For example, lets say we get ORA-01653: unable to extend table of error. How to check the size of the table and a tablespace? And how understanding is full?

    Thanks for your help

    Hello

    Select df.tablespace_name "Tablespace"

    totalusedspace 'Used MB',

    (df.totalspace - tu.totalusedspace) "MB free.

    DF. TotalSpace 'Total MB. "

    round (100 * ((df.totalspace-tu.totalusedspace) / df.totalspace))

    "PCT free."

    Of

    (select nom_tablespace,

    Round (Sum (bytes) / 1048576) TotalSpace

    from dba_data_files

    Group by tablespace_name) df,.

    (select round (sum (bytes) /(1024*1024)) totalusedspace, nom_tablespace)

    from dba_segments

    you group by tablespace_name)

    where df.tablespace_name = tu.tablespace_name

    and df.tablespace_name = "";

    For example, lets say we get ORA-01653: unable to extend table of error. How to check the size of the table and a tablespace? And how understanding is full?

    Is to say clearly to the question (you can let us know what you have understood so we can fix)

    [oracle@machine1 ~] $01653 oerr ora

    01653, 00000, "impossible to extend %s.%s table by %s in %s tablespace»

    * Cause: Failed to allocate a certain measure the required number of blocks for

    a segment of the table in the specified tablespace.

    * Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more

    storage of files indicate.

    -Thank you

    Pavan Kumar N

  • Creating table in the desired tablespace

    Hello

    I created the CUZK_BACKUP tablespace:


    CREATE the TABLESPACE CUZK_BACKUP DATAFILE ' / oradata/RUIAN/cuzk_backup01.dbf' SIZE 3 G AUTOEXTEND ON NEXT 100 M MAXSIZE 15 G;

    Now I'm trying to create table in this space of table like this:

    BEGIN

    -zjisti, if jiz existuji tabulky ve schematu centrumadmin (0 - no, 1 - year)

    SELECT COUNT (*) in the nCount_aud FROM dba_tables owner WHERE to = 'CENTRUMADMIN' and table_name = "$ _BACKUP2";

    SELECT COUNT (*) in the nCount_fga FROM dba_tables owner WHERE = 'CENTRUMADMIN' and table_name = "FGA_LOG$ _BACKUP2";

    IF (nCount_aud < = 0)-pokud tabulka neexistuje, vytvor ji partisnovanou po mesici

    THEN

    v_sql_aud: =' CREATE TABLE CENTRUMADMIN. AUD$ _BACKUP2

    TABLESPACE CUZK_BACKUP

    storage (initial 500 m next 50 m maxextents unlimited)

    PARTITION BY RANGE (NTIMESTAMP #)

    INTERVAL (NUMTOYMINTERVAL (1, "MONTHS"))

    (

    P_2013 PARTITION VALUES LOWER THAN (TO_DATE ("01/01/2014", "DD-MM-YYYY"));

    P_2014_01 PARTITION VALUES LOWER THAN (TO_DATE ("02/01/2014", "DD-MM-YYYY"));

    P_2014_02 PARTITION VALUES LOWER THAN (TO_DATE ("03/01/2014", "DD-MM-YYYY"));

    P_2014_03 PARTITION VALUES LOWER THAN (TO_DATE ("04/01/2014", "DD-MM-YYYY"));

    P_2014_04 PARTITION VALUES LOWER THAN (TO_DATE ("05/01/2014", "DD-MM-YYYY"));

    P_2014_05 PARTITION VALUES LESS THAN (TO_DATE ("06/01/2014", "DD-MM-YYYY")))

    AS select * from SYS. AUD$ where 1 = 2';

    EXECUTE IMMEDIATE v_sql_aud;

    DBMS_OUTPUT. Put_line ('Vytvorena tabulka CENTRUMADMIN.) AUD$ _BACKUP2.') ;

    ON THE OTHER

    DBMS_OUTPUT. Put_line (' CENTRUMADMIN Tabulka.) AUD$ _BACKUP2 jiz existuje.') ;

    END IF;

    Table is created, but not in the CUZK_BACKUP tablespace:

    Select table_name, tablespace_name from dba_tables where owner = "CENTRUMADMIN";

    TABLE_NAME, TABLESPACE_NAME

    ------------------------------ ------------------------------

    CUZK_SLUZBY OKO_USR_SCD

    CUZK_LOG_BEHU OKO_USR_SCD

    CUZK_LOG_FAZE OKO_USR_SCD

    CUZK_LOG_CHYBY OKO_USR_SCD

    AUD$ _BACKUP

    AUD$ _BACKUP2

    FGA_LOG$ _BACKUP

    FGA_LOG$ _BACKUP2

    Why there is no tablespace and how to make it work?

    Thank you

    Honza



    For a partitioned table, the actual segments are at the Partition level.  If a query DBA_TAB_PARTITIONS and DBA_SEGMENTS.

    Hemant K Collette

  • How to get the table without segment tablespace

    Hello

    I have a few tables in 11.2, which were created with creation of deferred segment and did so no segment/measure not yet. They already appear in dba_tables thus identical to the tab$, but do not have a defined tablespace.

    However, using dbms_metadata.get_ddl () the DOF resulting has the correct tablespace name. But what a view or table that I must query for this information with SQL?

    Thank you

    Robert

    Hello

    No, none of these tables is temporary, but it turns out that all the affected tables are ITO and so I have to check dba_indexes for the tablespace and the dba_indexes index_name when looking for a segment.

    Thank you

    Robert

  • Security move the table to another tablespace

    I would like to pass on my table to a different tablespace by using the statement:
    ALTER TABLE table_name move tablespace new_tablespace;

    I am interested in what happens if someone wants to select or modify some data during the process of alteration (on the table table_name). I tested on the database of test (without a users) and everything was OK, but I wonder what happens if someone edit or select data. Could you recommend me how to protect this table? Change in playback mode or change the database in the mode of restriction? Thanks for the tips.

    Hello

    The table is locked automatically during the MOVE ALTER TABLE. If other sessions can still perform selects, but no changes can be made during the DDL.
    Don't forget to re-create the indexes on the table later.

    Concerning
    Maurice

  • create the table with the parameters of storage in a locally managed tablespace

    Hello
    Can we create object with the parameters of storage in a locally managed tablespace.

    CREATE TABLE my_hash_table_6)
    name VARCHAR2 (30),
    value VARCHAR2 (4000))
    STORAGE)
    INITIAL 1 M
    NEXT 512K
    PCTINCREASE 0
    MINEXTENTS 2
    MAXEXTENTS UNLIMITED)


    default tablespace users is successful locallly.
    Then extended this table management will be managed according to the tablespace or storage settings which
    has been specified when the table was created.

    Hello

    This means that we don't have to define NEXT, PCTINCREASE, MAXEXTENTS at the object level.
    Then, these settings are applicable to Dictionary managed tablespace or what?

    Yes that's right, understand you is correct

    Can we define NEXT, PCTINCREASE, MAXEXTENTS at the level of the object in the dictionary managed tablespace;

    Yes, you can, but go for DMT, is not very good, because you advantages compared to LMT, just think about it before going to the DMT, than I suggest.

    -Pavan Kumar N
    Oracle 9i / 10g - OCP
    http://oracleinternals.blogspot.com/

  • Defragmentation of the tablespaces?

    DB version: 11.2.0.4

    Platform: Oracle Linux 6.5

    3-node RAC DB

    We have a TB 23 DB, and we met some performance issues lately. Sound mainly due to poorly written queries, large volume of data in the result set,... etc. But, this application was asked at a meeting if I could check that storage space (not tables) are fragmented. Apparently, in his old store DBA there did some 'Defragmenting' of tablespaces for the same application solve some performance problems.

    To resize the data files, move to another tablespace DB objects so that the HWM in a particular data file is reset and then we could run the RESIZE command. But this isn't "defragmentation".

    In the thread below, Justin cave explains that "a managed tablespace locally cannot effectively be fragmented."

    That Justin is meant by that? Why have we not need "defragmentation" to locally managed Tablespaces?

    Since I worked on 11g, I don't know the history. Done, DBA do a sort of defragmentation for older versions?

    https://community.Oracle.com/thread/2508361

    In general, you don't need to defragment of LMT because they re - operate segments more effectively.  That assumes a particular definition of the fragmentation that don't understand what some people call "Gruyère" fragmentation, which means free space holes, spread across the tablespace.  Sometimes it is wise to reclaim this space, generally do not, since generally the trend is to use space.

    Many more details are in the link given Aman, but there are a few somewhat obscure situations where you would not automatically exclude the defragmentation:

    A tablespace that has been migrated from DMT could have a few deferred maintenance on the lookout for defragmentation.

    You might still have DMTs.  You shouldn't, but there is nothing no longer this deferred maintenance upgrades of version (I do not forget something hope).

    Some applications do stupid things like add and remove tables and if done in a strange order (as drop any other individual and adding more), can travel on limits of segment requirements (as Jonathan explains in some links on the moving objects until the beginning of storage spaces).

    It is also possible to be unlucky and have performance issues based on the distribution of physical data get worse by moving data autour.

    In general, Oracle did some good things, but be prepared to do an investigation of mind, when it is not.  It allows to be confident and knowledgeable on the bases then.  For the 'fragmentation' in particular, a Manager may well have been seduced by myths or the specific practices that don't apply generally. "Best practices" may suffer, too.

  • ORA-01659: impossible to allocate MINEXTENTS beyond 2 in the tablespace test

    Hello

    I created a table and tried to insert records over 2 million and I'm getting an error such as ORA-01659: impossible to allocate MINEXTENTS beyond 2 in the tablespace test.

    Used tablespace percentage is only 73%.

    I used below when creating table

    tablespace TEST

    PCTFREE 10

    INITRANS 1

    maxtrans 255

    Please suggest me how to solve this problem.

    Thank you

    Suri

    Hi @Suri

    I see no problem in storage settings in your table.

    But the number of rows helps you insert and in the free space in your tablespace.

    Perhaps too much space is needed for your data and storage space can not support.

    The only things you can do is the following:

    (a) try PCT_INCREASE to 0, this product extensions to equal size.

    (b) put the PCT_FREE less than the default of 10. But it is advisable if you make updates to your table.

    (c) maybe create your table with the clause compress, just for bulk inserts, but this depends on the use of the table.

    (d) ask your DBA to increase the data files of the TEST table space or add more data files.

    (e) using the package DBMS_SPACE, you can calculate the space used by your table in tablespace TEST. g 10 and later versions.

    See the following example:

    
    SQL> SET SERVEROUTPUT ON
    
     SQL> DECLARE
       lc_tablespace       VARCHAR2(100)  DEFAULT 'CC_TBSD001_MOVI_DOMICILIOS';
       lc_megabytes        SIMPLE_INTEGER DEFAULT 1024*1024;
       lc_estimated_rows   SIMPLE_INTEGER DEFAULT 45000000;
       lc_pct_used         SIMPLE_INTEGER DEFAULT 10;
    
       l_cost_columns           SYS.CREATE_TABLE_COST_COLUMNS;
       l_mbytes_to_be_used      NUMBER;
       l_mbytes_to_be_allocated NUMBER;
    BEGIN
      l_cost_columns := SYS.CREATE_TABLE_COST_COLUMNS(
                 SYS.CREATE_TABLE_COST_COLINFO('NUMBER'  ,15)
                ,SYS.CREATE_TABLE_COST_COLINFO('NUMBER'  ,10)
                ,SYS.CREATE_TABLE_COST_COLINFO('NUMBER'  , 4)
                ,SYS.CREATE_TABLE_COST_COLINFO('VARCHAR2', 6)
                ,SYS.CREATE_TABLE_COST_COLINFO('VARCHAR2', 4)
                ,SYS.CREATE_TABLE_COST_COLINFO('NUMBER'  , 1)
                ,SYS.CREATE_TABLE_COST_COLINFO('NUMBER'  , 4)
                                                      );
    
       DBMS_SPACE.CREATE_TABLE_COST(lc_tablespace
                                   ,l_cost_columns
                                   ,lc_estimated_rows
                                   ,lc_pct_used
                                   ,l_mbytes_to_be_used
                                   ,l_mbytes_to_be_allocated
                                   );
    
       l_mbytes_to_be_used      := l_mbytes_to_be_used/lc_megabytes;
       l_mbytes_to_be_allocated := l_mbytes_to_be_allocated/lc_megabytes;
    
       DBMS_OUTPUT.PUT_LINE('Megabytes to be used: '||TO_CHAR(l_mbytes_to_be_used));
       DBMS_OUTPUT.PUT_LINE('Megabytes to be allocated: '||TO_CHAR(l_mbytes_to_be_allocated));
    END;
    /
    

    A few ref, pleas read

    http://docs.Oracle.com/CD/B28359_01/server.111/b28286/clauses009.htm#SQLRF30013

    Hope this can help you.

    Kind regards

    Juan M

  • Changing table via the package with immediate execution (problem)

    Hello

    I have a unusual problem. I have a package that contains the procedure that via execute immediate statement, creates a table on which he performs different actions for example:

    -alter table some_owner.dummy_table noparallel

    -create index some_owner.idx_name on some_owner.dummy_table (column)...

    But I only managed to run move and create synonym table/public via execute immediate statement. Actions as alter table and create index fails with error ORA-01031: insufficient privileges.

    Note If call these commands outside the package (a simple script) this all done OK.

    I found a way, where I set the AUTHID CURRENT_USER command create package statement. In this way all the actions executed OK.

    I wonder why I can't change the table via the package with immediate execution on a table that is in the tablespace "SOME_TABLESPACE" and the title of owner "SOME_OWNER", without putting the AUTHID command on the package.

    There must be a problem why a package cannot change the table which is owned by the user 'SOME_OWNER '.

    All useful responses would be appreciated.

    I have a unusual problem.

    No - you don't have. This question has been answered SEVERAL times on this forum and others.

    But I only managed to run move and create synonym table/public via execute immediate statement. Actions as alter table and create index fails with error ORA-01031: insufficient privileges.

    OK - your username doesn't have privileges to do these operations or only received privileges through roles.

    Roles are DISABLED in named PL/SQL blocks that use of the AUTHOR's rights.

    Note If call these commands outside the package (a simple script) this all done OK.

    I found a way, where I set the AUTHID CURRENT_USER command create package statement. In this way all the actions executed OK.

    Of course - the roles are NOT disabled in named PL/SQL blocks that use the rights of the APPELLANT or in anonymous blocks.

    I wonder why I can't change the table via the package with immediate execution on a table that is in the tablespace "SOME_TABLESPACE" and the title of owner "SOME_OWNER", without putting the AUTHID command on the package.

    Well now you know!

  • collect statistics for the tablespace

    Friends...

    OS: Linux

    DB: 11 GR 2

    Data size: 1 TB

    I spend monthly multiple partitioned table spaces and bring together in a single annual partition. (for example tbs_2014_01, tbs_2014_02 - tbs_2014_12... all combine them into tbs_2014 as a tablespace)

    Over the weekend, work of database gets executed that collects statistics that are obsolete, it collects all the segments that have been moved from the storage.

    Given that the collection of statistics at the end of the week takes too long, I tried to find a smart way to collect statistics after each tablespace move rather than waiting for job to weekend which will take two or three days to complete.

    1. is there a way to gather statistics at the tablespace level and collect statistics for all objects in this table space?

    2. how to determine the overall stats of collection of statistics part?

    That is, suppose I have move the tbs_2014_01 tablespace and collect statistics with global stats that could take 2 hours but it will be difficult to spend 2 hours for each stats global tablespace which in my opinion is not good and we should be collecting global stats only once.

    3. any other advice?

    977272 wrote:

    @sol.beach... Thanks for your comments...

    I've not been asked to collect statistics to the tablespace but level to collect statistics after that finish objects move in storage.

    Given the size of the data, it is difficult to gather all the statistics at the weekend so trying to understand another method to collect the statistics the weekend load will be less.

    You can collect statistics object on an object by object basis level after that each object has been moved.

Maybe you are looking for

  • Update BIOS password on the Satellite P200

    Hello I had a model number P200 laptop computer satellite PSPB6E-03G02TEN fongr in the last two months. On the navigation of the Toshiba support and dowloads I looked up my model etc number to see what that downloads were available. Is he saying ther

  • 6552 channel input impedance

    Hello I am trying to acquire an output of my DUT using the 6552 map, and the 6552 50 ohms default channel input impedance. It's pulling down of my output, so I want to change the impedance of 10K or 50K entry but I can't seem to do. When I run the ex

  • Installation problem Windows 10 on Acer Aspire V5 - 573G

    I have acer aspire V5 - 573G, I tried to install Windows 10 on my computer using the USB. I started on USB, format hard drive and tired to install it, but he gave me error "Windows cannot install required files. Make sure all files required for insta

  • Windows file extension keeps opening every 2 minutes?

    Windows leader continues expansion opening every 2 minutes, I have like 8 windows open automatically, how do I stop?

  • lose 3 hours on the date/time stamp

    I have a hp Pavilion slimline desktop computer. Several times a month I'll lose 3 hours on time. No more and no less. I'll fix this issue (on change date and time settings). I have other things on the same outlet including a digital clock is not able