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

2022-05-05 07:36:08 字數 1774 閱讀 4893

1、建立使用者:

create user toptea2 identified by "使用者名稱"

2、給使用者授權

grant create session to 使用者名稱;

grant create table to 使用者名稱;

grant create tablespace to 使用者名稱;

grant create view to 使用者名稱;

3、查詢表空間大小

select file_name,bytes/1024/1024||'m' "size" from dba_data_files;

4、建立表空間

create tablespace 表空間名 datafile '/data/oracle/oradata/nmcdesign/表空間名 .dbf' size 2048m autoextend on next 10m maxsize unlimited;

1) datafile: 表空間資料檔案存放路徑

2) size: 起初設定為200m

3) uniform: 指定區尺寸為128k,如不指定,區尺寸預設為64k

4) 空間名稱histdb 與 資料檔案名稱 histdb.dbf 不要求相同,可隨意命名.

5) autoextend on/off 表示啟動/停止自動擴充套件表空間

6) alter database datafile ' d:oracleproduct10.2.0oradataorclhistdb.dbf ' resize 500m; //手動修改資料文

tempfile是指臨時檔案,用於指定臨時表空間的儲存檔案,

datafile是指資料檔案,用於儲存資料的檔案,

5、給使用者指定表空間

alter user 使用者名稱 default tablespace 表空間名 

6、匯出「使用者名稱」使用者的資料

參考:expdp 使用者名稱/密碼@資料庫名 schemas=toptea dumpfile=toptea.dmp logfile=日誌名稱.log

匯出檔案會放在:oracle/admin/nmcdesign/dpdump路徑下

7、匯入資料

(1)改變使用者匯入:

impdp 使用者名稱1/密碼@資料庫名 dumpfile=備份檔案.dmp remap_schema=使用者名稱1:使用者名稱2

(2)改變表空間匯入

建立directory 虛擬路徑 但是必須的有這個路徑,不然會報錯

create directory directory_name as '備份檔案的路徑

賦讀寫許可權到這個路徑

grant read,write on directory directory_name  to 使用者名稱; 

匯入資料

impdp  使用者名稱1/密碼@資料庫名 dumpfile=備份檔案.dmp  remap_schema=使用者名稱1:使用者名稱2  directory=toptea3 remap_tablespace=ftoptea:users

(3)跨版本匯入

跨版本匯入必須在發出時指定oraacle版本

expdp 使用者名稱/密碼@資料庫名 schemas=toptea dumpfile=toptea.dmp logfile=日誌名稱.log  version=10.2.0.5.0 (目標資料庫版本)

impdp 使用者名稱1/密碼@資料庫名 dumpfile=備份檔案.dmp remap_schema=使用者名稱1:使用者名稱2

8、匯出表

使用者名稱/密碼@資料庫名 tables = 表名 dumpfile=匯出檔案.dmp logfile=日誌檔案.log

oracle建立表空間並且給使用者賦許可權

建立表空間並指定表空間的大小 create tablespace stockea tbs extent management local segment space management auto 2.建使用者 create user stockea1 identified by stockea d...

oracle建立表空間,建立使用者

建立臨時表空間 create temporary tablespace test temp tempfile e oracle product 10.2.0 oradata testserver test temp01.dbf size 32m autoextend on next 32m maxs...

oracle建立表空間,建立使用者

建立臨時表空間 create temporary tablespace test temp tempfile e oracle product 10.2.0 oradata testserver test temp01.dbf size 32m autoextend onnext 32m maxsi...