oracle 10g 用戶管理筆記

Oracle用戶管理筆記
1.創建用戶
sql>conn system/manager
sql>create user xiaoming identfied by m123; //密碼必須以字母開頭,而且默認新建的用戶是沒有登陸數據庫的權限的

2.修改密碼
sql>show user;
sql>password xiaoming //回車輸入口令

3.刪除用戶(在刪除用戶是注意,如果刪除的用戶,已經創建了表,那麼就必須要在刪除時帶上一個參數 cascade)
sql>drop user xiaoming;

4.賦權限
1)賦連接數據庫權限
sql>conn system/manager;
sql>grant connect to xiaoming;// 賦連接數據庫權限
sql>conn xiaoming/m123; //現在可以登陸成功了

2)賦創建表權限
sql>conn system/manager;
sql>grant resource to xiaoming; // 賦創建表權限
sql>conn xiaoming/m123;
sql>create table test(userId varchar2(20),username varchar2(30));
sql>desc test;

3)使xiaoming用戶可以去查詢scott的emp表
sql>conn scott/m123;
sql>grant select on emp to xiaoming; // 賦xiaoming可以查詢scott的emp表的權限,
sql>conn xiaoming/m123;
sql>set linesize 120;
sql>set pagesize 200;
sql>select * from scott.emp; //xiaoming用戶可以訪問scott裏邊的emp表了
使xiaoming用戶可以去修改/刪除/查詢/添加scott的emp表
sql>grant all on emp to xiaoming; //all就是對這張表的所有權限賦予小明

4)收回權限(scott希望收回xiaoming對emp表的查詢權限)
sql>conn scott/m123;
sql>revoke select on emp from xiaoming;

對權限的維護
希望xiaoming用戶可以去查詢scott的emp表,還希望xiaoming可以把這個權限賦予別的用戶
如果是對象權限,就加入with grant option
sql>conn scott/m123
sql>grant select on emp to xiaoming with grant option

sql>conn system/manager;
sql>create user xiaohong identified by m123;
sql>grant connect to xiaohong;

sql>conn xiaoming/m123;
sql>grant select on scott.emp to xiaohong;
如果是系統權限.
system給xiaoming權限時:
sql>grant connect to xiaoming with admin option;

使用profile管理用戶口令
1.創建profile文件
sql>create profile locak_account limit failed_login_attempts 3 password_lock_time 2;
sql>alter user xiaoming profile locak_account; //用戶輸入2次錯誤密碼時,用戶將鎖定2天。

2.給鎖定用戶解鎖
sql>conn system/manager;
sql>alter user xiaoming account unlock; //解鎖xiaoming用戶

3.終止用戶
sql>create profile myprofile limit password_life_time 10 password_grace_time 2;
sql>alter user xiaoming profile myprofile;

4.口令歷史
建立profile
sql>creater profile password_history limit password_life_time 10 password_grace_time 2 password_reuse_time 10;

password_reuse_time //指定口令重用時間即10天后可以重用

5.刪除profile
sql>drop profile password_history

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章