Oracle建立使用者

2021-05-27 19:47:25 字數 4734 閱讀 2154

create user user_name identified by user_password;

grant resource,connect,dba to user_name;

create user "[username]"  

profile "default"

identified by "[userpassword]" 

default tablespace "[tablespace]"

temporary tablespace "[tablespace]"

account unlock;

grant"connect" to "[username]" with admin option;

grant"dba" to "[username]" with admin option;

一、建立

sys;//系統管理員,擁有最高許可權

system;//本地管理員,次高許可權

scott;//普通使用者,密碼預設為tiger,預設未解鎖

sys;//系統管理員,擁有最高許可權

system;//本地管理員,次高許可權

scott;//普通使用者,密碼預設為tiger,預設未解鎖

二、登陸

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;//在管理員帳戶下,建立使用者zhangsan

alert user scott identified by tiger;//修改密碼

create user zhangsan;//在管理員帳戶下,建立使用者zhangsan

alert user scott identified by tiger;//修改密碼

四,授予許可權

1、預設的普通使用者scott預設未解鎖,不能進行那個使用,新建的使用者也沒有任何許可權,必須授予許可權

/*管理員授權*/

grant create session to zhangsan;//授予zhangsan使用者建立session的許可權,即登陸許可權

grant unlimited session to zhangsan;//授予zhangsan使用者使用表空間的許可權

grant create table to zhangsan;//授予建立表的許可權

grante drop table to zhangsan;//授予刪除表的許可權

grant insert table to zhangsan;//插入表的許可權

grant update table to zhangsan;//修改表的許可權

grant all to public;//這條比較重要,授予所有許可權(all)給所有使用者(public)

/*管理員授權*/

grant create session to zhangsan;//授予zhangsan使用者建立session的許可權,即登陸許可權

grant unlimited session to zhangsan;//授予zhangsan使用者使用表空間的許可權

grant create table to zhangsan;//授予建立表的許可權

grante drop table to zhangsan;//授予刪除表的許可權

grant insert table to zhangsan;//插入表的許可權

grant update table to zhangsan;//修改表的許可權

grant all to public;//這條比較重要,授予所有許可權(all)給所有使用者(public)

2、oralce對許可權管理比較嚴謹,普通使用者之間也是預設不能互相訪問的,需要互相授權

/*oralce對許可權管理比較嚴謹,普通使用者之間也是預設不能互相訪問的*/

grant select on tablename to zhangsan;//授予zhangsan使用者檢視指定表的許可權

grant drop on tablename to zhangsan;//授予刪除表的許可權

grant insert on tablename to zhangsan;//授予插入的許可權

grant update on tablename to zhangsan;//授予修改表的許可權

grant insert(id) on tablename to zhangsan;

grant update(id) on tablename to zhangsan;//授予對指定表特定欄位的插入和修改許可權,注意,只能是insert和update

grant alert all table to zhangsan;//授予zhangsan使用者alert任意表的許可權

/*oralce對許可權管理比較嚴謹,普通使用者之間也是預設不能互相訪問的*/

grant select on tablename to zhangsan;//授予zhangsan使用者檢視指定表的許可權

grant drop on tablename to zhangsan;//授予刪除表的許可權

grant insert on tablename to zhangsan;//授予插入的許可權

grant update on tablename to zhangsan;//授予修改表的許可權

grant insert(id) on tablename to zhangsan;

grant update(id) on tablename to zhangsan;//授予對指定表特定欄位的插入和修改許可權,注意,只能是insert和update

grant alert all table to zhangsan;//授予zhangsan使用者alert任意表的許可權

五、撤銷許可權

基本語法同grant,關鍵字為revoke

基本語法同grant,關鍵字為revoke

六、檢視許可權

select * from user_sys_privs;//檢視當前使用者所有許可權

select * from user_tab_privs;//檢視所用使用者對錶的許可權

select * from user_sys_privs;//檢視當前使用者所有許可權

select * from user_tab_privs;//檢視所用使用者對錶的許可權

七、操作表的使用者的表

/*需要在表名前加上使用者名稱,如下*/

select * from zhangsan.tablename

/*需要在表名前加上使用者名稱,如下*/

select * from zhangsan.tablename

八、許可權傳遞

即使用者a將許可權授予b,b可以將操作的許可權再授予c,命令如下:

grant alert table on tablename to zhangsan with admin option;//關鍵字 with admin option

grant alert table on tablename to zhangsan with grant option;//關鍵字 with grant option效果和admin類似

grant alert table on tablename to zhangsan with admin option;//關鍵字 with admin option

grant alert table on tablename to zhangsan with grant option;//關鍵字 with grant option效果和admin類似

九、角色

角色即許可權的集合,可以把乙個角色授予給使用者

create role myrole;//建立角色

grant create session to myrole;//將建立session的許可權授予myrole

grant myrole to zhangsan;//授予zhangsan使用者myrole的角色

drop role myrole;刪除角色

/*但是有些許可權是不能授予給角色的,比如unlimited tablespace和any關鍵字*/

Oracle 使用者建立

執行 cmd 進入 dos視窗 c sqlplus sys password as sysdba 使用sys使用者登入 sql create user username identified by password 建立使用者名稱和密碼 sql create tablespace ts userna...

Oracle建立使用者

當你建立使用者時,應該定義它的表空間 default tablespace 否則,它會使用系統表空間 system tablespace 這是應該避免的。這是常用的建立使用者的乙個例子 create user xx identified by xx profile default default t...

oracle 建立使用者

oracle10g建立使用者 oracle10g 的建立使用者名稱 1 linux 下oracle 的啟動以 oracle 身份登入 啟動lsnrctl start 登入sqplus nolog 連線資料庫 connect assysdba 啟動資料庫 startup 關閉資料庫 shutdown ...