The important thing in life is to have a great aim , and the determination

          導航

          <2014年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          留言簿(7)

          隨筆分類

          隨筆檔案

          文章檔案

          相冊

          閱讀排行榜

          評論排行榜

          常用鏈接

          統(tǒng)計

          IT技術鏈接

          保險相關

          友情鏈接

          基金知識

          生活相關

          最新評論

          oracle修改密碼、添加用戶及授權

        1. 忘記密碼處理

          登錄:sqlplus/as sysdba;
          修改:alter user username identified by 密碼;

        2. 創(chuàng)建新用戶

          create user 用戶名 identified by 密碼 default tablespace 表空間名

        3. 用戶授權

          Grant create session to SYSDATA;//授予SYSDATA連接數(shù)據(jù)的權限
          系統(tǒng)權限如下:
          Create session:連接數(shù)據(jù)庫
          Create sequence:創(chuàng)建序列
          Create synonym:創(chuàng)建同名對象
          Create table:創(chuàng)建表
          Create any table:創(chuàng)建任何模式的表
          Drop table:刪除表
          Create procedure:創(chuàng)建存儲過程
          Execute any procedure:執(zhí)行任何模式的存儲過程
          Create user:創(chuàng)建用戶
          Create view:創(chuàng)建視圖
          Drop user:刪除用戶
          Drop any table:刪除任何模式的表
          向用戶授予系統(tǒng)特權

          Grant execute any procedure toSYSDATA with admin option
          此句意思為為sha用戶創(chuàng)建系統(tǒng)特權并且可以用SYSDATA為別的用戶授予權限

          連接SYSDATA用戶connect SYSDATA/admin

          可以創(chuàng)建別的用戶

          查看用戶權限

          進入SYSDATA用戶connect SYSDATA/admin

          Select * from user_sys_privs;可以查看到一個列表,
          列代表用戶名權限是否可以給別的用戶附加權限(N、Y)

          行代表權限都有那些

          撤銷用戶授予的權限

          必須連接connect system/admin

          撤銷權限r(nóng)evoke是系統(tǒng)撤銷權限的關鍵詞

          Revoke execute any procedure from SYSDATA;
          更改用戶密碼

          進入SYSDATA用戶connect SYSDATA/admin

          Password輸入舊密碼輸入新密碼倆邊OK

          或者用alter user SYSDATA identified by xinmima

          刪除用戶

          Connect system/admin
          Drop user SYSDATA;
          為用戶授予角色

          Grant dba to SYSDATA;
          Grant connect to SYSDATA;
          Linux下的plsql創(chuàng)建用戶

          create user SYSDATA identified by admin
          Default tablespace user
          Temporary tablespace temp;
          Granr unlimited tablespace to SYSDATA;//權限
          Grant dba to SYSDATA;//角色
          Grant connect to SYSDATA;

          select * from dba_users; //用戶表
          select * from dba_tablespaces; //表空間

          http://database.51cto.com/art/200911/160296.htm

          Oracle 權限設置
          一、權限分類:
          系統(tǒng)權限:系統(tǒng)規(guī)定用戶使用數(shù)據(jù)庫的權限。(系統(tǒng)權限是對用戶而言)。
          實體權限:某種權限用戶對其它用戶的表或視圖的存取權限。(是針對表或視圖而言的)。

          二、系統(tǒng)權限管理:
          1、系統(tǒng)權限分類:
          DBA: 擁有全部特權,是系統(tǒng)最高權限,只有DBA才可以創(chuàng)建數(shù)據(jù)庫結構。
          RESOURCE:擁有Resource權限的用戶只可以創(chuàng)建實體,不可以創(chuàng)建數(shù)據(jù)庫結構。
          CONNECT:擁有Connect權限的用戶只可以登錄Oracle,不可以創(chuàng)建實體,不可以創(chuàng)建數(shù)據(jù)庫結構。
          對于普通用戶:授予connect, resource權限。
          對于DBA管理用戶:授予connect,resource, dba權限。

          2、系統(tǒng)權限授權命令:
          [系統(tǒng)權限只能由DBA用戶授出:sys, system(最開始只能是這兩個用戶)]
          授權命令:SQL> grant connect, resource, dba to 用戶名1 [,用戶名2]…;
          [普通用戶通過授權可以具有與system相同的用戶權限,但永遠不能達到與sys用戶相同的權限,system用戶的權限也可以被回收。]
          例:
          SQL> connect system/manager
          SQL> Create user user50 identified by user50;
          SQL> grant connect, resource to user50;
          查詢用戶擁有哪里權限:
          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)權限傳遞:
          增加WITH ADMIN OPTION選項,則得到的權限可以傳遞。
          SQL> grant connect, resorce to user50 with admin option; //可以傳遞所獲權限。

          4、系統(tǒng)權限回收:系統(tǒng)權限只能由DBA用戶回收
          命令:SQL> Revoke connect, resource from user50;

          說明:
          1)如果使用WITH ADMIN OPTION為某個用戶授予系統(tǒng)權限,那么對于被這個用戶授予相同權限的所有用戶來說,取消該用戶的系統(tǒng)權限并不會級聯(lián)取消這些用戶的相同權限。
          2)系統(tǒng)權限無級聯(lián),即A授予B權限,B授予C權限,如果A收回B的權限,C的權限不受影響;系統(tǒng)權限可以跨用戶回收,即A可以直接收回C用戶的權限。

          三、實體權限管理
          1、實體權限分類:select, update, insert, alter, index, delete, all //all包括所有權限
          execute //執(zhí)行存儲過程權限
          user01:
          SQL> grant select, update, insert on product to user02;
          SQL> grant all on product to user02;
          user02:
          SQL> select * from user01.product;
          // 此時user02查user_tables,不包括user01.product這個表,但如果查all_tables則可以查到,因為他可以訪問。

          2. 將表的操作權限授予全體用戶:
          SQL> grant all on product to public; // public表示是所有的用戶,這里的all權限不包括drop。
          [實體權限數(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; // 獲權可以存取的表(被授權的)
          SQL> select grantee, owner, table_name, privilege from user_tab_privs; // 授出權限的表(授出的權限)

          3. DBA用戶可以操作全體用戶的任意基表(無需授權,包括刪除):
          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;

          4. 實體權限傳遞(with grant option):
          user01:
          SQL> grant select, update on product to user02 with grant option; // user02得到權限,并可以傳遞。

          5. 實體權限回收:
          user01:
          SQL>Revoke select, update on product from user02; //傳遞的權限將全部丟失。

          說明
          1)如果取消某個用戶的對象權限,那么對于這個用戶使用WITH GRANT OPTION授予權限的用戶來說,同樣還會取消這些用戶的相同權限,也就是說取消授權時級聯(lián)的。

          Oracle 用戶管理
          一、創(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ù)字,請用雙引號括起來
          default tablespace account
          temporary tablespace temp
          profile default
          quota 50m on account;
          SQL> grant connect, resource to acc01;
          [*] 查詢用戶缺省表空間、臨時表空間
          SQL> select username, default_tablespace, temporary_tablespace from dba_users;
          [*] 查詢系統(tǒng)資源文件名:
          SQL> select * from dba_profiles;
          資源文件類似表,一旦創(chuàng)建就會保存在數(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、修改用戶臨時表空間
          SQL> Alter user acc01 temporary tablespace temp_data;
          4、強制用戶修改口令字:
          SQL> Alter user acc01 password expire;
          5、將用戶加鎖
          SQL> Alter user acc01 account lock; // 加鎖
          SQL> Alter user acc01 account unlock; // 解鎖

          四、刪除用戶
          SQL>drop user 用戶名; //用戶沒有建任何實體
          SQL> drop user 用戶名 CASCADE; // 將用戶及其所建實體全部刪除
          *1. 當前正連接的用戶不得刪除。

          五、監(jiān)視用戶:
          1、查詢用戶會話信息:
          SQL> select username, sid, serial#, machine from v$session;
          2、刪除用戶會話信息:
          SQL> Alter system kill session ‘sid, serial#’;
          3、查詢用戶SQL語句:
          SQL> select user_name, sql_text from v$open_cursor;

          Oracle 角色管理
          一、何為角色
            角色。角色是一組權限的集合,將角色賦給一個用戶,這個用戶就擁有了這個角色中的所有權限。

          二、系統(tǒng)預定義角色
            預定義角色是在數(shù)據(jù)庫安裝后,系統(tǒng)自動創(chuàng)建的一些常用的角色。下介簡單的介紹一下這些預定角色。角色所包含的權限可以用以下語句查詢:
          sql>select * from role_sys_privs where role=’角色名’;

          1.CONNECT, RESOURCE, DBA
          這些預定義角色主要是為了向后兼容。其主要是用于數(shù)據(jù)庫管理。oracle建議用戶自己設計數(shù)據(jù)庫管理和安全的權限規(guī)劃,而不要簡單的使用這些預定角色。將來的版本中這些角色可能不會作為預定義角色。

          2.DELETE_CATALOG_ROLE, EXECUTE_CATALOG_ROLE, SELECT_CATALOG_ROLE
          這些角色主要用于訪問數(shù)據(jù)字典視圖和包。

          3.EXP_FULL_DATABASE, IMP_FULL_DATABASE
          這兩個角色用于數(shù)據(jù)導入導出工具的使用。

          4.AQ_USER_ROLE, AQ_ADMINISTRATOR_ROLE
          AQ:Advanced Query。這兩個角色用于oracle高級查詢功能。

          5. SNMPAGENT
          用于oracle enterprise manager和Intelligent Agent

          6.RECOVERY_CATALOG_OWNER
          用于創(chuàng)建擁有恢復庫的用戶。關于恢復庫的信息,參考oracle文檔《Oracle9i User-Managed Backup and Recovery Guide》

          7.HS_ADMIN_ROLE
          A DBA using Oracle’s heterogeneous services feature needs this role to access appropriate tables in the data dictionary.

          三、管理角色
          1.建一個角色
          sql>create role role1;

          2.授權給角色
          sql>grant create any table,create procedure to role1;

          3.授予角色給用戶
          sql>grant role1 to user1;

          4.查看角色所包含的權限
          sql>select * from role_sys_privs;

          5.創(chuàng)建帶有口令以角色(在生效帶有口令的角色時必須提供口令)
          sql>create role role1 identified by password1;

          6.修改角色:是否需要口令
          sql>alter role role1 not identified;
          sql>alter role role1 identified by password1;

          7.設置當前用戶要生效的角色
          (注:角色的生效是一個什么概念呢?假設用戶a有b1,b2,b3三個角色,那么如果b1未生效,則b1所包含的權限對于a來講是不擁有的,只有角色生效了,角色內(nèi)的權限才作用于用戶,最大可生效角色數(shù)由參數(shù)MAX_ENABLED_ROLES設定;在用戶登錄后,oracle將所有直接賦給用戶的權限和用戶默認角色中的權限賦給用戶。)
          sql>set role role1;//使role1生效
          sql>set role role,role2;//使role1,role2生效
          sql>set role role1 identified by password1;//使用帶有口令的role1生效
          sql>set role all;//使用該用戶的所有角色生效
          sql>set role none;//設置所有角色失效
          sql>set role all except role1;//除role1外的該用戶的所有其它角色生效。
          sql>select * from SESSION_ROLES;//查看當前用戶的生效的角色。

          8.修改指定用戶,設置其默認角色
          sql>alter user user1 default role role1;
          sql>alter user user1 default role all except role1;
          詳見oracle參考文檔

          9.刪除角色
          sql>drop role role1;
          角色刪除后,原來擁用該角色的用戶就不再擁有該角色了,相應的權限也就沒有了。

          說明:
          1)無法使用WITH GRANT OPTION為角色授予對象權限
          2)可以使用WITH ADMIN OPTION 為角色授予系統(tǒng)權限,取消時不是級聯(lián)

        4. posted on 2014-05-02 11:05 鴻雁 閱讀(208) 評論(0)  編輯  收藏 所屬分類: 數(shù)據(jù)庫

          主站蜘蛛池模板: 正阳县| 精河县| 孙吴县| 绵阳市| 多伦县| 高要市| 永和县| 宣威市| 公主岭市| 广安市| 闸北区| 罗平县| 利辛县| 随州市| 蓬溪县| 新巴尔虎左旗| 武乡县| 定远县| 商水县| 吉水县| 沭阳县| 芜湖市| 大港区| 淮南市| 千阳县| 阿坝县| 滨州市| 舟山市| 东乡县| 舟曲县| 琼海市| 大关县| 柳河县| 徐闻县| 科技| 乐亭县| 涡阳县| 濮阳市| 喜德县| 宁南县| 元阳县|