oracle資料庫管理

2021-06-06 08:35:36 字數 4544 閱讀 1070

當乙個oracle

例項建立了之後,會自動建立

system

和sys使用者

區別:對於兩者之間的區別,就類似 sys

使用者是董事長,

system

使用者是總經理

具體的區別如下:

·儲存的資料的重要性不同

sys:所有的oracle

的資料字典的基表和動態檢視都存放在

sys使用者中,這些基表和檢視對

oracle

來說是至關重要的,有資料庫自己來維護,任何使用者不能手動修改,

sys使用者是擁有最高許可權的使用者

system:存放的是一些次要級的資料,如

oracle

的一些特性或者工具的管理資訊,擁有的許可權也很高

·許可權不同

sys:必須要用sysdba

或者sysoper

的身份才能登陸

system:可以使用sysdba

的身份登陸,也可以使用

normal

的身份登陸,如果以

sysdba

身份登陸的話,那麼就是相當於

sys使用者

sysdba 與 

sysoper 

身份的區別:

sysdba擁有最高的系統許可權,登陸後是 

syssysoper主要用來啟動、關閉資料庫,

sysoper 

登陸後使用者是 

public

sysdba和

sysoper

屬於system privilege

,也稱為

administrative privilege

,擁有例如資料庫開啟關閉之類一些系統管理級別的許可權

sysdba

和sysoper

具體的許可權可以看下表:

系統許可權

sysdba

sysoper 區別

startup(啟動資料庫

)startup

shutdown(關閉資料庫

)shutdown

alter database open/mount/backup

alter database open/mount/backup

改變字符集

none

create database(建立資料庫

)none不能建立資料庫

drop database(刪除資料庫

)none

create spfile

create spfile

alter database archivelog(歸檔日誌

)alter database archivelog

alter database recover(恢復資料庫

)只能完全恢復,不能執行不完全恢復

擁有restricted session(

會話限制)許可權

擁有restricted session

許可權可以讓使用者作為sys

使用者連線

可以進行一些基本的操作,但不能檢視使用者資料

登入之後使用者是sys

登入之後使用者是public

dba使用者:

dba使用者是指具有

dba角色的資料庫使用者,特殊使用者(

sys)可以關閉和啟動資料庫,但是普的

dba使用者不能進行

邏輯備份和物理備份

匯出(邏輯備份):匯出可以分為匯出表,匯出方案,匯出資料三種,用exp命令來完成

,常用的選項有:

userid:用於指定執行匯出操作的使用者名稱,密碼,連線字串

tables: 用於指定匯出操作的表

owner: 用於指定執行匯出操作的方案

full: = y/n 使用者指定匯出操作的資料庫

inctype:  用於指定匯出操作的增量型別

rows: =y/n 用於指定執行匯出操作是否要匯出表中的資料

file: 用於指定匯出的路徑以及檔名

compress: 用於匯出的時候壓縮檔案

要進行匯出操作,可以在oracle

的d:\oracle\ora92\bin

下面建立乙個

.bat檔案,

把命令寫在

.bat

檔案裡面,也可以在

dos命令下面輸入,但是要先進入到這個資料夾中;

·匯出表

|- 匯出自身的表

exp  userid=scott/tiger@hwt 

tables

=(emp) file=d:\scott_emp.dmp;

|- 匯出其他方案的表

如果使用者要匯出其他的方案的表,則需要dba的角色或是

exp_full_database

的許可權,比如system

就可以匯出

scottt表

exp userid=system/manager@hwt tables=(scott.emp,scott.dept)  file=d:\system_emp_dept.dmp;

|- 只匯出表的結構

exp  userid=scott/tiger@hwt 

tables

=(emp) file=d:\scott_emp.dmp rows=n;

//rows=n 意思就是不匯出資料,只是匯出結構

|- 直接匯出

exp  userid=scott/tiger@hwt 

tables

=(emp) file=d:\scott_emp.dmp direct=y;

直接匯出的速度很快,尤其在匯入大物件的時候速度很快

直接匯出的限制 :1. 匯出表空間必須使用傳統模式。

2. 含有lob物件的表不支援直接匯出模式。

3. 直接匯出不支援query.

4. 直接匯出模式使用recordlength設定一次可以匯出資料的量,傳統模式使用buffer設定.

5. 低版本直接匯出模式要求匯出客戶端和資料庫字符集設定一致。

·匯出方案

|- 匯出自己的方案

exp  userid=scott/tiger@hwt  owner=scott  file=d:\scott_shema.dmp;

|- 匯出其他的方案

匯出其他的方案必須具有dba

的角色,或者具有

exp_full_database

的許可權,如:system

可以匯出任何的方案

exp  userid=system/manager@hwt  owner=(system,scott)  file=d:\scott_shema.dmp;

·匯出資料庫

匯出資料庫必須具有dba

的角色或者是

exp_full_database

的許可權,同時因為匯出資料的時間很長,而且不容易成功完成整個資料庫的匯出,所以少用

|- exp userid=system/manager@hwt  full=y  inctype=complete file=d:\hwt.dmp

匯入(邏輯恢復)

·匯入表

|- 匯入自己的表

imp  userid=scott/tiger@hwt 

tables

=(emp) file=d:\scott_emp.dmp;

|- 匯入別人的表

(需要dba

角色或者

exp_full_database

的許可權)

imp  userid=system/manager@hwt 

tables

=(emp) 

touser=hwt 

file=d:\scott_emp.dmp;

|- 匯入表結構

imp  userid=scott/tiger@hwt 

tables

=(emp) rows=n

file=d:\scott_emp.dmp;

|- 匯入表的資料(如果表的結果存在,就只匯入資料)

imp  userid=scott/tiger@hwt 

tables

=(emp) ignore=y

file=d:\scott_emp.dmp;

注意的是,備份檔案必須是自己這個使用者匯出的,要不就用dba

許可權來匯入給別的方案

·匯入方案

|- 匯入自身的方案

imp  userid=scott/tiger@hwt file=d:\scott_schema.dmp;

|- 匯入其他的方案(需要有

dba的許可權)

imp  userid=sytem/manger@hwt 

fromuser=system touser=scott 

file=d:\scott_schema.dmp;

·匯入資料庫

|- 匯入資料庫

在預設情況下,匯入資料庫會匯入物件結構和資料

(前提是要有匯出資料庫的那個使用者,這個使用者要先存在)

imp  userid=system/manager@hwt full=y 

file=d:\db_hwt.dmp;

Oracle 資料庫使用者管理

oracle 許可權設定 一 許可權分類 系統許可權 系統規定使用者使用資料庫的許可權。系統許可權是對使用者而言 實體許可權 某種許可權使用者對其它使用者的表或檢視的訪問許可權。是針對表或檢視而言的 二 系統許可權管理 1 系統許可權分類 dba 擁有全部特權,是系統最高許可權,只有dba才可以建立...

oracle資料庫使用者管理

執行 cmd 按如下輸入命令 sqlplus as sysdba 以sys登陸 超級使用者 sysdba alter user 使用者名稱 account unlock 解除鎖定 必須帶 號 alter user 使用者名稱 identified 密碼 修改密碼 然後用你改好的密碼登陸就行 如果可以...

Oracle資料庫管理操作

資料庫啟動關閉 關閉資料庫 shutdown 開啟資料庫 startup 資料庫的備份與恢復 邏輯備份 使用工具export將資料物件的結構和資料匯出到檔案的過程。邏輯恢復 使用工具import利用備份的檔案將資料物件匯入到資料庫的過程。物理備份即可在資料庫open狀態下進行,也可在關閉資料庫後進行...