oracle下匯出某使用者下的表

2021-09-01 16:51:41 字數 3347 閱讀 3852

scott/tiger是使用者名稱和密碼,handson是匯出的例項名

² 按使用者方式匯出資料(owner當中寫的是使用者名稱)

exp scott/tiger@handson file=scott_back owner=scott

² 按表方式匯出資料(talbes當中寫的是全部表的名稱)

exp scott/tiger@handson tables=(emp, dept) file=scott_back_tab

² 按表空間方式匯出資料(tablespaces當中寫的是表空間名稱)

exp system/handson@handson tablespaces=(users) file=tbs_users

² 使用引數檔案匯出資料

exp system/handson parfile='c:\parameters.txt

1、cmd->exp->username/passwd@sid-->.....一路回車--->輸入匯出庫得名字 就把所有的表、檢視、儲存過程、函式、作業等亂七八糟的都匯出來了;

2、pl/sql-->工具---〉匯出使用者物件 可以找到你要導的東東。

兩者都可以的很方便!

匯出表: exp scott/tiger@mycon tables=(dept,emp) file=tab1.dmp

匯出使用者: exp system/manager@mycon owner=scott file=usr1.dmp

匯出資料庫:

1.完全匯出 exp system/manager@mycon full=y inctype=complete file=full1.dmp

2.增量匯出 exp system/manager@mycon full=y inctype=incremental file=inc1.dmp

3.累積匯出 exp system/manager@mycon full=y inctype=cumulative file=cum1.dmp

匯入表: imp system/manager@mycon file=c:\tab1.dmp tables=(dept,emp) touser=scott

匯入使用者: imp system/manager@mycon file=usr1.dmp fromuser=scott touser=scott

匯入資料庫:

1.全庫匯入 imp system/manager@mycon file=full1.dmp full=y

2.增量匯入

1)匯入資料庫最新資訊 imp system/manager@mycon inctype=system full=y file=inc7.dmp 2)匯入最近完全匯出檔案 imp system/manager@mycon inctype=restore full=y file=full1.dmp

3)匯入所有累積匯出檔案 imp system/manager@mycon inctype=restore full=y file=cum1.dmp

4)匯入最近一次增量匯出的檔案 imp system/manager@mycon inctype=restore full=y file=inc1.dmp

常用的命令

exp user/password@instance file=file.dmp rows=y log=log_name

其中username/password為匯出使用者的使用者名稱和密碼

instance為匯出的例項名

rows是指定是否要匯入表中的行

匯出乙個使用者下的表結構為sql檔案:

使用命令好像匯出的都是dmp檔案

可以使用plsql軟體在tools--àexport user object

如果不要到處table space ,不要勾include storage

選擇匯出的路徑檔名,export可以直接匯出了

例子1:(本方法限oracle9i版本以上)

set pagesize 0

set long 90000

set feedback off

set echo off

spool get_allddl.sql

connect username/password@sid;

select dbms_metadata.get_ddl('table',u.table_name)

from user_tables u;

select dbms_metadata.get_ddl('index',u.index_name)

from user_indexes u;

spool off;

例子2:

首先在sqlplus下以該使用者登入到oracle資料庫,然後將以下內容貼上到sqlplus中:

set feedback off;

set pagesize 0;

set heading off;

set verify off;

set linesize 200;

set trimspool on;

spool c:\資料庫備份.bat;

select 'exp username/ffffff@yourdb tables='||table_name||' file='||table_name||'.dmp triggers=n' from user_tables;

spool off;

set feedback on;

set pagesize 9999;

set heading on;

set verify on;

exit

完成後在找到 c:\資料庫備份.bat 檔案,編輯該批處理檔案,將第一行和最後一行刪掉,儲存後執行該批處理檔案就可全部匯出該使用者下的所有表。

oracle下匯入某使用者所有表的方法

² 將整個檔案匯入資料庫

imp system/handson@handosn file=item_back.dmp ignore=y full=y

² 將scott使用者的表匯入到martin使用者

imp system/handson@handosn file=scott_back fromuser=scott touser=martin tables=(emp,dept)

² 使用引數檔案匯入資料

imp system/oracle parfile='c:\parameters.txt

常用命令

imp username/password file=file.dmp fromuser=user1 touser=user2 rows=y

其中username/password為匯入到資料庫的使用者名稱和密碼

fromuser為備份資料庫時的使用者

touser為匯入資料庫的使用者,一般和username同

oracle批量刪除某使用者下的表

昨天幹了一天的體力活,到快下班時被要求刪除一批測試庫上錯誤的表,主要是這些表的字段和生產上欄位順序對不上,然後讓我寫個指令碼,讓dba執行一下,主要是刪表這種東西我們都沒許可權.然後,我就被難到了,我記得以前都是刪乙個表啊,還沒有批量刪過表啊,而且以前刪表都是先刪除約束再刪表的,難道這次讓我去把每個...

oracle下匯出某使用者所有表的方法

oracle下匯出某使用者所有表的方法 scott tiger是使用者名稱和密碼,handson是匯出的例項名 按使用者方式匯出資料 owner當中寫的是使用者名稱 exp scott tiger handson file scott back owner scott 按表方式匯出資料 talbes...

oracle 怎樣查詢某使用者下的所有表的表名

select from all tab comments 查詢所有使用者的表,檢視等。select from user tab comments 查詢本使用者的表,檢視等。select from all col comments 查詢所有使用者的表的列名和注釋。select from user co...