一. 創(chuàng)建表并插入數(shù)據(jù)

SQL> create table t1 as select * from scott.dept;

Table created.

SQL> select * from t1;

    DEPTNO DNAME          LOC                                                  
---------- -------------- -------------                                        
        10 ACCOUNTING     NEW YORK                                             
        20 RESEARCH       DALLAS                                               
        30 SALES          CHICAGO                                              
        40 OPERATIONS     BOSTON  

二. 導出

SQL> exp  -- 找不到該命令
SP2-0042: unknown command "exp" - rest of line ignored.
SQL> host exp  -- 在exp命令前加上host

提示輸入
username: 
scott/tiger@orcl   --如果是管理員則加上 as sysdba

Enter array fetch buffer size: 4096 > 回車

Export file: Expdat.dmp > e:\testexp.dmp  -- 導出文件存放位置

(2)U(sers), or (3)(ables): (2)U > 回車 -- 導出方式, 這里只列出用戶方式和表方式, 如果是以管理員身份, 則有三種方式, 即整個數(shù)據(jù)庫.

Export grants (yes/no): yes > 回車 --是否導出權(quán)限

Export table data (yes/no): yes >回車 -- 是否導出表中數(shù)據(jù)

compress extents (yes/no): yes >回車 -- 是否用壓縮區(qū)

...  這樣就把scott的所有對象導出了.



三. 導入

SQL> imp  -- 找不到該命令
SP2-0042: unknown command "imp" - rest of line ignored.
SQL> host imp -- 在imp命令前加上host

提示輸入
username: 
scott/tiger@orcl   --如果是管理員則加上 as sysdba

Import file: EXPDAT.DMP > e:\testexp.dmp  -- 導入文件存放位置

Enter insert buffer size (minimum is 8192) 30720) >回車

List contents of import file only(yes/no): no >回車

ignore create error due to object existence (yes/no): no > yes -- 如果對象已經(jīng)存在, 則忽略

import grants (yes/no): yes >回車 -- 是否導入權(quán)限

import table data (yes/no): yes >回車 -- 是否導入表中數(shù)據(jù)

import entire export file (yes/no): no >no

username: scott -- 從哪個用戶導入.

Enter table(T) or partition(T:P) names. Null list means all tales for user

Enter table(T) or partition(T:P) name or . if done: t1 -- T 表示普通表, T:P 表示表空間.