Oracle 用戶權(quán)限管理方法
更新時(shí)間:2009年08月15日 02:02:37 作者:
Oracle 用戶權(quán)限管理方法,對(duì)于想要學(xué)習(xí)oracle安全的朋友,是個(gè)入門級(jí)的資料。
sys;//系統(tǒng)管理員,擁有最高權(quán)限
system;//本地管理員,次高權(quán)限
scott;//普通用戶,密碼默認(rèn)為tiger,默認(rèn)未解鎖
sys;//系統(tǒng)管理員,擁有最高權(quán)限
system;//本地管理員,次高權(quán)限
scott;//普通用戶,密碼默認(rèn)為tiger,默認(rèn)未解鎖
二、登陸
sqlplus / as sysdba;//登陸sys帳戶
sqlplus sys as sysdba;//同上
sqlplus scott/tiger;//登陸普通用戶scott
sqlplus / as sysdba;//登陸sys帳戶
sqlplus sys as sysdba;//同上
sqlplus scott/tiger;//登陸普通用戶scott
三、管理用戶
create user zhangsan;//在管理員帳戶下,創(chuàng)建用戶zhangsan
alert user scott identified by tiger;//修改密碼
create user zhangsan;//在管理員帳戶下,創(chuàng)建用戶zhangsan
alert user scott identified by tiger;//修改密碼
四,授予權(quán)限
1、默認(rèn)的普通用戶scott默認(rèn)未解鎖,不能進(jìn)行那個(gè)使用,新建的用戶也沒(méi)有任何權(quán)限,必須授予權(quán)限
/*管理員授權(quán)*/
grant create session to zhangsan;//授予zhangsan用戶創(chuàng)建session的權(quán)限,即登陸權(quán)限
grant unlimited session to zhangsan;//授予zhangsan用戶使用表空間的權(quán)限
grant create table to zhangsan;//授予創(chuàng)建表的權(quán)限
grante drop table to zhangsan;//授予刪除表的權(quán)限
grant insert table to zhangsan;//插入表的權(quán)限
grant update table to zhangsan;//修改表的權(quán)限
grant all to public;//這條比較重要,授予所有權(quán)限(all)給所有用戶(public)
/*管理員授權(quán)*/
grant create session to zhangsan;//授予zhangsan用戶創(chuàng)建session的權(quán)限,即登陸權(quán)限
grant unlimited session to zhangsan;//授予zhangsan用戶使用表空間的權(quán)限
grant create table to zhangsan;//授予創(chuàng)建表的權(quán)限
grante drop table to zhangsan;//授予刪除表的權(quán)限
grant insert table to zhangsan;//插入表的權(quán)限
grant update table to zhangsan;//修改表的權(quán)限
grant all to public;//這條比較重要,授予所有權(quán)限(all)給所有用戶(public)
2、oralce對(duì)權(quán)限管理比較嚴(yán)謹(jǐn),普通用戶之間也是默認(rèn)不能互相訪問(wèn)的,需要互相授權(quán)
/*oralce對(duì)權(quán)限管理比較嚴(yán)謹(jǐn),普通用戶之間也是默認(rèn)不能互相訪問(wèn)的*/
grant select on tablename to zhangsan;//授予zhangsan用戶查看指定表的權(quán)限
grant drop on tablename to zhangsan;//授予刪除表的權(quán)限
grant insert on tablename to zhangsan;//授予插入的權(quán)限
grant update on tablename to zhangsan;//授予修改表的權(quán)限
grant insert(id) on tablename to zhangsan;
grant update(id) on tablename to zhangsan;//授予對(duì)指定表特定字段的插入和修改權(quán)限,注意,只能是insert和update
grant alert all table to zhangsan;//授予zhangsan用戶alert任意表的權(quán)限
/*oralce對(duì)權(quán)限管理比較嚴(yán)謹(jǐn),普通用戶之間也是默認(rèn)不能互相訪問(wèn)的*/
grant select on tablename to zhangsan;//授予zhangsan用戶查看指定表的權(quán)限
grant drop on tablename to zhangsan;//授予刪除表的權(quán)限
grant insert on tablename to zhangsan;//授予插入的權(quán)限
grant update on tablename to zhangsan;//授予修改表的權(quán)限
grant insert(id) on tablename to zhangsan;
grant update(id) on tablename to zhangsan;//授予對(duì)指定表特定字段的插入和修改權(quán)限,注意,只能是insert和update
grant alert all table to zhangsan;//授予zhangsan用戶alert任意表的權(quán)限
五、撤銷權(quán)限
基本語(yǔ)法同grant,關(guān)鍵字為revoke
基本語(yǔ)法同grant,關(guān)鍵字為revoke
六、查看權(quán)限
select * from user_sys_privs;//查看當(dāng)前用戶所有權(quán)限
select * from user_tab_privs;//查看所用用戶對(duì)表的權(quán)限
select * from user_sys_privs;//查看當(dāng)前用戶所有權(quán)限
select * from user_tab_privs;//查看所用用戶對(duì)表的權(quán)限
七、操作表的用戶的表
/*需要在表名前加上用戶名,如下*/
select * from zhangsan.tablename
/*需要在表名前加上用戶名,如下*/
select * from zhangsan.tablename
八、權(quán)限傳遞
即用戶A將權(quán)限授予B,B可以將操作的權(quán)限再授予C,命令如下:
grant alert table on tablename to zhangsan with admin option;//關(guān)鍵字 with admin option
grant alert table on tablename to zhangsan with grant option;//關(guān)鍵字 with grant option效果和admin類似
grant alert table on tablename to zhangsan with admin option;//關(guān)鍵字 with admin option
grant alert table on tablename to zhangsan with grant option;//關(guān)鍵字 with grant option效果和admin類似
九、角色
角色即權(quán)限的集合,可以把一個(gè)角色授予給用戶
create role myrole;//創(chuàng)建角色
grant create session to myrole;//將創(chuàng)建session的權(quán)限授予myrole
grant myrole to zhangsan;//授予zhangsan用戶myrole的角色
drop role myrole;刪除角色
/*但是有些權(quán)限是不能授予給角色的,比如unlimited tablespace和any關(guān)鍵字*/
system;//本地管理員,次高權(quán)限
scott;//普通用戶,密碼默認(rèn)為tiger,默認(rèn)未解鎖
sys;//系統(tǒng)管理員,擁有最高權(quán)限
system;//本地管理員,次高權(quán)限
scott;//普通用戶,密碼默認(rèn)為tiger,默認(rèn)未解鎖
二、登陸
sqlplus / as sysdba;//登陸sys帳戶
sqlplus sys as sysdba;//同上
sqlplus scott/tiger;//登陸普通用戶scott
sqlplus / as sysdba;//登陸sys帳戶
sqlplus sys as sysdba;//同上
sqlplus scott/tiger;//登陸普通用戶scott
三、管理用戶
create user zhangsan;//在管理員帳戶下,創(chuàng)建用戶zhangsan
alert user scott identified by tiger;//修改密碼
create user zhangsan;//在管理員帳戶下,創(chuàng)建用戶zhangsan
alert user scott identified by tiger;//修改密碼
四,授予權(quán)限
1、默認(rèn)的普通用戶scott默認(rèn)未解鎖,不能進(jìn)行那個(gè)使用,新建的用戶也沒(méi)有任何權(quán)限,必須授予權(quán)限
/*管理員授權(quán)*/
grant create session to zhangsan;//授予zhangsan用戶創(chuàng)建session的權(quán)限,即登陸權(quán)限
grant unlimited session to zhangsan;//授予zhangsan用戶使用表空間的權(quán)限
grant create table to zhangsan;//授予創(chuàng)建表的權(quán)限
grante drop table to zhangsan;//授予刪除表的權(quán)限
grant insert table to zhangsan;//插入表的權(quán)限
grant update table to zhangsan;//修改表的權(quán)限
grant all to public;//這條比較重要,授予所有權(quán)限(all)給所有用戶(public)
/*管理員授權(quán)*/
grant create session to zhangsan;//授予zhangsan用戶創(chuàng)建session的權(quán)限,即登陸權(quán)限
grant unlimited session to zhangsan;//授予zhangsan用戶使用表空間的權(quán)限
grant create table to zhangsan;//授予創(chuàng)建表的權(quán)限
grante drop table to zhangsan;//授予刪除表的權(quán)限
grant insert table to zhangsan;//插入表的權(quán)限
grant update table to zhangsan;//修改表的權(quán)限
grant all to public;//這條比較重要,授予所有權(quán)限(all)給所有用戶(public)
2、oralce對(duì)權(quán)限管理比較嚴(yán)謹(jǐn),普通用戶之間也是默認(rèn)不能互相訪問(wèn)的,需要互相授權(quán)
/*oralce對(duì)權(quán)限管理比較嚴(yán)謹(jǐn),普通用戶之間也是默認(rèn)不能互相訪問(wèn)的*/
grant select on tablename to zhangsan;//授予zhangsan用戶查看指定表的權(quán)限
grant drop on tablename to zhangsan;//授予刪除表的權(quán)限
grant insert on tablename to zhangsan;//授予插入的權(quán)限
grant update on tablename to zhangsan;//授予修改表的權(quán)限
grant insert(id) on tablename to zhangsan;
grant update(id) on tablename to zhangsan;//授予對(duì)指定表特定字段的插入和修改權(quán)限,注意,只能是insert和update
grant alert all table to zhangsan;//授予zhangsan用戶alert任意表的權(quán)限
/*oralce對(duì)權(quán)限管理比較嚴(yán)謹(jǐn),普通用戶之間也是默認(rèn)不能互相訪問(wèn)的*/
grant select on tablename to zhangsan;//授予zhangsan用戶查看指定表的權(quán)限
grant drop on tablename to zhangsan;//授予刪除表的權(quán)限
grant insert on tablename to zhangsan;//授予插入的權(quán)限
grant update on tablename to zhangsan;//授予修改表的權(quán)限
grant insert(id) on tablename to zhangsan;
grant update(id) on tablename to zhangsan;//授予對(duì)指定表特定字段的插入和修改權(quán)限,注意,只能是insert和update
grant alert all table to zhangsan;//授予zhangsan用戶alert任意表的權(quán)限
五、撤銷權(quán)限
基本語(yǔ)法同grant,關(guān)鍵字為revoke
基本語(yǔ)法同grant,關(guān)鍵字為revoke
六、查看權(quán)限
select * from user_sys_privs;//查看當(dāng)前用戶所有權(quán)限
select * from user_tab_privs;//查看所用用戶對(duì)表的權(quán)限
select * from user_sys_privs;//查看當(dāng)前用戶所有權(quán)限
select * from user_tab_privs;//查看所用用戶對(duì)表的權(quán)限
七、操作表的用戶的表
/*需要在表名前加上用戶名,如下*/
select * from zhangsan.tablename
/*需要在表名前加上用戶名,如下*/
select * from zhangsan.tablename
八、權(quán)限傳遞
即用戶A將權(quán)限授予B,B可以將操作的權(quán)限再授予C,命令如下:
grant alert table on tablename to zhangsan with admin option;//關(guān)鍵字 with admin option
grant alert table on tablename to zhangsan with grant option;//關(guān)鍵字 with grant option效果和admin類似
grant alert table on tablename to zhangsan with admin option;//關(guān)鍵字 with admin option
grant alert table on tablename to zhangsan with grant option;//關(guān)鍵字 with grant option效果和admin類似
九、角色
角色即權(quán)限的集合,可以把一個(gè)角色授予給用戶
create role myrole;//創(chuàng)建角色
grant create session to myrole;//將創(chuàng)建session的權(quán)限授予myrole
grant myrole to zhangsan;//授予zhangsan用戶myrole的角色
drop role myrole;刪除角色
/*但是有些權(quán)限是不能授予給角色的,比如unlimited tablespace和any關(guān)鍵字*/
相關(guān)文章
oracle 視圖權(quán)限 oracle 創(chuàng)建視圖權(quán)限不足
在scott用戶下創(chuàng)建視圖的時(shí)候,報(bào)錯(cuò):權(quán)限不足,遇到這個(gè)問(wèn)題,我也是束手無(wú)策,于是網(wǎng)上搜集整理了一下,曬出來(lái)和大家分享,希望可以幫助你們2012-11-11
Oracle DECODE 丟失時(shí)間精度的原因與解決方案
在Oracle數(shù)據(jù)庫(kù)中使用DECODE函數(shù)處理DATE類型數(shù)據(jù)時(shí),可能會(huì)丟失時(shí)分秒信息,這主要是因?yàn)镈ECODE在處理時(shí)進(jìn)行了自動(dòng)類型轉(zhuǎn)換,通常只比較日期部分,忽略時(shí)間部分,解決這一問(wèn)題的方法是使用CASE WHEN語(yǔ)句,它可以更精確地處理DATE類型數(shù)據(jù),避免時(shí)間信息的丟失2024-10-10
Oracle SQL性能優(yōu)化系列學(xué)習(xí)三
Oracle SQL性能優(yōu)化系列學(xué)習(xí)三...2007-03-03
ORACLE SQL語(yǔ)句優(yōu)化技術(shù)要點(diǎn)解析
這篇文章主要介紹了ORACLE SQL語(yǔ)句優(yōu)化技術(shù)的相關(guān)內(nèi)容,小編覺(jué)得挺不錯(cuò)的,在這里分享給大家,需要的朋友可以參考下。2017-10-10
Oracle中pivot函數(shù)圖文實(shí)例詳解
pivot操作是一種數(shù)據(jù)處理方法,可以將一個(gè)表中的行數(shù)據(jù)轉(zhuǎn)換為列數(shù)據(jù),這種轉(zhuǎn)換對(duì)于表格數(shù)據(jù)的分析和展示非常有用,下面這篇文章主要給大家介紹了關(guān)于Oracle中pivot函數(shù)的相關(guān)資料,需要的朋友可以參考下2023-05-05
oracle求同比,環(huán)比函數(shù)(LAG與LEAD)的詳解
本篇文章是對(duì)oracle求同比,環(huán)比函數(shù)(LAG與LEAD)進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05

