oracle資料從乙個表空間匯入到另外乙個表空間

2021-08-30 21:17:17 字數 1144 閱讀 4771

問題:在使用exp匯出使用者資料後,再使用imp匯入時,必須保證兩者物件的表空間一致才能成功匯入

在此分享一點解決辦法:

exp匯出使用者資料:exp userid=user/user owner=user file=user.dmp

匯出表ddl:開啟pl/sql執行選單:「工具」->「匯出使用者物件」功能, 選擇所有的表,不選擇儲存,匯出為文user_tables.sql

建立表結構:使用目標使用者登陸pl/sql後,執行:user_tables.sql

刪除約束sql:

select 'alter table ' || owner || '.' || table_name || ' drop constraint ' || constraint_name || ' cascade;' 

from dba_constraints dc where dc.owner='user';

-- 生成刪除主,外建的**,複製出來 執行即可刪除約束

刪除索引:

select 'drop index ' || owner || '.' || index_name || ' ;' from dba_indexes di where di.owner='user' and di.table_type='table' and di.uniqueness!='unique' order by di.table_name, di.index_name;

-- 查詢後,複製出來,執行後就可以禁止索引

匯入資料:imp userid=other/other fromuser=user touser=other  ignore=y indexes=n constraints=n buffer=102400000 feedback=1000000 file=user.dmp

重建約束(包括:主鍵、外來鍵)和索引:執行users_tables.sql即可<--因為之前刪除掉了原來的約束和索引

oracle語句表資料從一張表匯入另乙個表

類似與sql server 的語句,從乙個表中取得一些資料匯入到另乙個新錶或者已經存在的表 sql server select column1,column2,into new table from old table 加入到新錶中 insert into end table column1,col...

ORACLE建立使用者,表空間,並且匯出資料,匯出表

1 建立使用者 create user toptea2 identified by 使用者名稱 2 給使用者授權 grant create session to 使用者名稱 grant create table to 使用者名稱 grant create tablespace to 使用者名稱 gr...

mysql 從乙個表中查資料,插入另乙個表

類別一 如果兩張張表 匯出表和目標表 的字段一致,並且希望插入全部資料,可以用這種方法 insert into 目標表select from 表 例如,要將 articles 表插入到 newarticles 表中,則可以通過如下sql語句實現 insert into newarticles sel...