1. 程式人生 > 實用技巧 >cmd下操作oracle資料

cmd下操作oracle資料

1.cmd視窗下,登陸管理員使用者:sqlplus sys/1 as sysdba

2.建立新使用者併為使用者授權:

  (1)建立使用者

---Create the user
create user Helq3_Pro
identified by "1"
default tablespace MOF
temporary tablespace TEMP
profile DEFAULT;

  (2)為使用者授權

SQL> grant dba to helq3_cpbgt_20200714 with admin option;
SQL> grant unlimited tablespace to
helq3_cpbgt_20200714 with admin option; SQL> grant imp_full_database to helq3_cpbgt_20200714;

3.資料匯入

  (1)imp匯入:imp userid=helq3_cpbgt_20200714/1@orcl file=E:\cpcz.dmp full=yignore=y 

  (2)資料泵匯入impdp

    首先,建立,併為使用者授權此資料夾

    資料泵匯入:impdp helq3_cpbgt_20200714/1 dumpfile=cpcz.dmp directory=expdp_dir remap_schema=helq3_cpbgt_20200714(匯出時的使用者名稱):helq3_cpbgt_20200714

4.資料匯出

  (1)exp匯出: exp helq3_cpbgt_20200714/1@orcl file=E:\cpcz.dmp log=cpcz.log

    匯出帶空表的資料庫->先做查詢,再正常匯出:select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0;

  (2)expdp 資料泵匯出:expdp helq3_cpbgt_20200714/1@orclschemas=helq3_cpbgt_20200714 dumpfile=cpcz.dmp directory=expdp_dir logfile=cpcz.log