日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Oracle用户、权限、角色管理

發(fā)布時(shí)間:2023/12/4 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Oracle用户、权限、角色管理 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Oracle 數(shù)據(jù)庫用戶管理Oracle 權(quán)限設(shè)置
一、權(quán)限分類:
系統(tǒng)權(quán)限:系統(tǒng)規(guī)定用戶使用數(shù)據(jù)庫的權(quán)限。(系統(tǒng)權(quán)限是對(duì)用戶而言)。實(shí)體權(quán)限:某種權(quán)限用戶對(duì)其它用戶的表或視圖的存取權(quán)限。(是針對(duì)表或視圖而言的)。二、系統(tǒng)權(quán)限管理:
1、系統(tǒng)權(quán)限分類:
DBA: 擁有全部特權(quán),是系統(tǒng)最高權(quán)限,只有DBA才可以創(chuàng)建數(shù)據(jù)庫結(jié)構(gòu)。RESOURCE:擁有Resource權(quán)限的用戶只可以創(chuàng)建實(shí)體,不可以創(chuàng)建數(shù)據(jù)庫結(jié)構(gòu)。CONNECT:擁有Connect權(quán)限的用戶只可以登錄Oracle,不可以創(chuàng)建實(shí)體,不可以創(chuàng)建數(shù)據(jù)庫結(jié)構(gòu)。對(duì)于普通用戶:授予connect, resource權(quán)限。
對(duì)于DBA管理用戶:授予connect,resource, dba權(quán)限。2、系統(tǒng)權(quán)限授權(quán)命令:
[系統(tǒng)權(quán)限只能由DBA用戶授出:sys, system(最開始只能是這兩個(gè)用戶)]
授權(quán)命令:SQL> grant connect, resource, dba to 用戶名1 [,用戶名2]...;[普通用戶通過授權(quán)可以具有與system相同的用戶權(quán)限,但永遠(yuǎn)不能達(dá)到與sys用戶相同的權(quán)限,system用戶的權(quán)限也可以被回收。]例:
SQL> connect system/manager
SQL> Create user user50 identified by user50;
SQL> grant connect, resource to user50;查詢用戶擁有哪里權(quán)限:
SQL> select * from dba_role_privs;
SQL> select * from dba_sys_privs;
SQL> select * from role_sys_privs;刪除用戶:SQL> drop user 用戶名 cascade; //加上cascade則將用戶連同其創(chuàng)建的東西全部刪除3、系統(tǒng)權(quán)限傳遞:
增加WITH ADMIN OPTION選項(xiàng),則得到的權(quán)限可以傳遞。SQL> grant connect, resorce to user50 with admin option; //可以傳遞所獲權(quán)限。4、系統(tǒng)權(quán)限回收:系統(tǒng)權(quán)限只能由DBA用戶回收
命令:SQL> Revoke connect, resource from user50;系統(tǒng)權(quán)限無級(jí)聯(lián),即A授予B權(quán)限,B授予C權(quán)限,如果A收回B的權(quán)限,C的權(quán)限不受影響;系統(tǒng)權(quán)限可以跨用戶回收,即A可以直接收回C用戶的權(quán)限。三、實(shí)體權(quán)限管理
1、實(shí)體權(quán)限分類:select, update, insert, alter, index, delete, all //all包括所有權(quán)限
execute //執(zhí)行存儲(chǔ)過程權(quán)限user01:
SQL> grant select, update, insert on product to user02;
SQL> grant all on product to user02;user02:
SQL> select * from user01.product;// 此時(shí)user02查user_tables,不包括user01.product這個(gè)表,但如果查all_tables則可以查到,因?yàn)樗梢栽L問。
3. 將表的操作權(quán)限授予全體用戶:
SQL> grant all on product to public; // public表示是所有的用戶,這里的all權(quán)限不包括drop。[實(shí)體權(quán)限數(shù)據(jù)字典]:
SQL> select owner, table_name from all_tables; // 用戶可以查詢的表
SQL> select table_name from user_tables; // 用戶創(chuàng)建的表
SQL> select grantor, table_schema, table_name, privilege from all_tab_privs; // 獲權(quán)可以存取的表(被授權(quán)的)
SQL> select grantee, owner, table_name, privilege from user_tab_privs; // 授出權(quán)限的表(授出的權(quán)限)4. DBA用戶可以操作全體用戶的任意基表(無需授權(quán),包括刪除):
DBA用戶:
SQL> Create table stud02.product(
id number(10),
name varchar2(20));
SQL> drop table stud02.emp;SQL> create table stud02.employee
as
select * from scott.emp;

5. 實(shí)體權(quán)限傳遞(with grant option):
user01:SQL> grant select, update on product to user02 with grant option; // user02得到權(quán)限,并可以傳遞。6. 實(shí)體權(quán)限回收:
user01:
SQL>Revoke select, update on product from user02; //傳遞的權(quán)限將全部丟失。
一、創(chuàng)建用戶的Profile文件
SQL> create profile student limit // student為資源文件名
FAILED_LOGIN_ATTEMPTS 3 //指定鎖定用戶的登錄失敗次數(shù)
PASSWORD_LOCK_TIME 5 //指定用戶被鎖定天數(shù)
PASSWORD_LIFE_TIME 30 //指定口令可用天數(shù)
二、創(chuàng)建用戶
SQL> Create User username
Identified by password
Default Tablespace tablespace
Temporary Tablespace tablespace
Profile profile
Quota integer/unlimited on tablespace;例:
SQL> Create user acc01
identified by acc01 // 如果密碼是數(shù)字,請(qǐng)用雙引號(hào)括起來
default tablespace account
temporary tablespace temp
profile default
quota 50m on account;
SQL> grant connect, resource to acc01;[*] 查詢用戶缺省表空間、臨時(shí)表空間
SQL> select username, default_tablespace, temporary_tablespace from dba_users;[*] 查詢系統(tǒng)資源文件名:
SQL> select * from dba_profiles;
資源文件類似表,一旦創(chuàng)建就會(huì)保存在數(shù)據(jù)庫中。
SQL> select username, profile, default_tablespace, temporary_tablespace from dba_users;SQL> create profile common limit
failed_login_attempts 5
idle_time 5;

SQL> Alter user acc01 profile common;三、修改用戶:
SQL> Alter User 用戶名
Identified 口令
Default Tablespace tablespace
Temporary Tablespace tablespace
Profile profile
Quota integer/unlimited on tablespace;

1、修改口令字:
SQL>Alter user acc01 identified by "12345";2、修改用戶缺省表空間:
SQL> Alter user acc01 default tablespace users;3、修改用戶臨時(shí)表空間
SQL> Alter user acc01 temporary tablespace temp_data;4、強(qiáng)制用戶修改口令字:
SQL> Alter user acc01 password expire;5、將用戶加鎖
SQL> Alter user acc01 account lock; // 加鎖
SQL> Alter user acc01 account unlock; // 解鎖四、刪除用戶
SQL>drop user 用戶名; //用戶沒有建任何實(shí)體
SQL> drop user 用戶名 CASCADE; // 將用戶及其所建實(shí)體全部刪除*1. 當(dāng)前正連接的用戶不得刪除。
五、監(jiān)視用戶:
1、查詢用戶會(huì)話信息:
SQL> select username, sid, serial#, machine from v$session;2、刪除用戶會(huì)話信息:
SQL> Alter system kill session 'sid, serial#';3、查詢用戶SQL語句:
SQL> select user_name, sql_text from v$open_cursor;SQL> ALTER SESSION SET
NLS_LANGUAGE= 'SIMPLIFIED CHINESE'
NLS_TERRITORY= 'CHINA'
NLS_CURRENCY= 'RMB'
NLS_ISO_CURRENCY= 'CHINA'
NLS_NUMERIC_CHARACTERS= '.,'
NLS_CALENDAR= 'GREGORIAN'
NLS_DATE_FORMAT= 'yyyy-mm-dd dy'
NLS_DATE_LANGUAGE= 'SIMPLIFIED CHINESE'
NLS_SORT= 'BINARY'
TIME_ZONE= '+08:00'
NLS_DUAL_CURRENCY = 'RMB'
NLS_TIME_FORMAT = 'HH.MI.SSXFF AM'
NLS_TIMESTAMP_FORMAT = 'DD-MON-RR HH.MI.SSXFF AM'
NLS_TIME_TZ_FORMAT = 'HH.MI.SSXFF AM TZH:TZM'
NLS_TIMESTAMP_TZ_FORMAT = 'DD-MON-RR HH.MI.SSXFF AM TZH:TZM'
一、Oracle 權(quán)限管理
SQL> grant connect, resource, dba to acc01;SQL> revoke connect, resource from acc01;二、Oracle 角色管理SQL> Create Role <role_name>
Identified by password/ Not Identified;

SQL> Alter Role <role_name> ...SQL> Grant <privs> to <role_name>;SQL> Grant <role_name> to <user_name>SQL> Set Role <role_name>
All Except <role_name2> / None

本文出自 “shell” 博客,請(qǐng)務(wù)必保留此出處http://dusong.blog.51cto.com/158065/139284


轉(zhuǎn)載于:https://blog.51cto.com/xu3jin/1312829

總結(jié)

以上是生活随笔為你收集整理的Oracle用户、权限、角色管理的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。