数据库中的表分别分布在几个不同的表空间,如何他表都放到一个表空间?

解决方案 »

  1.   


    alter table move tablespace 
      

  2.   

    表A从表空间USER转到表空间TEST
    ALTER TABLE A MOVE TABLESPACE TEST;10G的文档是这么说的:
    Moving a table changes the rowids of the rows in the table. This causes indexes on the table to be ed UNUSABLE, and DML accessing the table using these indexes will receive an ORA-01502 error. The indexes on the table must be dropped or rebuilt. Likewise, any statistics for the table become invalid and new statistics should be collected after moving the table.
      

  3.   

    declare   
      CURSOR get_t IS
       SSelect t.table_name
      From User_Tables t;
    begin
      -- Test statements here
       FOR rec_ IN get_t LOOP
           Begin
                Alter Table rec_.table_name Move Tablespace New_Tablespace;  
           EXCEPTION
              WHEN OTHERS THEN
                 dbms_output.put_line('error:'||Sqlerrm);
           END;
       END LOOP;  
    end;
      

  4.   

    最好还是使用EXP/IMP或EXPDP/IMPDP命令吧,效率会比MOVE命令的效率高。
    如果在执行EXP/EXPDP命令时,导出了索引的话,在IMP/IMPDP时,也会导入索引,而无需重建索引。
    并且该命令支持并行操作。
      

  5.   


    现在是这样的,用imp导入的话,如果导入的新库中的表空间与dmp文件中含有的表空间信息一致的话,就是你指定自己的表空间也是没有用的。
    比如,导出的dmp文件中有从users表空间导出的数据,那么你再倒入新库的时候,数据仍然会写到新库的users表空间,是没有办法更改的,入过新库没有users表空间,那么会报错吧。
      

  6.   

    更正一下,剛才有做測試,索引要重建.alter index index_name rebuild ;
      

  7.   

    这个问题是由于创建用户时用户权限没有设置好产生的:  revoke unlimited tablespace on 需移出表空间 from  用户名;
      alter  user 用户名 quota 0 on user;
      ALTER   USER   用户名 QUOTA   UNLIMITED   ON    目的表空间;  
      
      

  8.   


    imp/impdp在导入数据时,肯定可以将表导入指定的表空间中,方法是:
    1、将目标用户的默认表空间改为要导入的表空间名称,并保证该用户在表空间上有足够的配额。
    2、用户目标用户执行Imp/impdp操作。