Oracle(4)建立使用者,分配許可權及角色,Schema概念
阿新 • • 發佈:2019-01-06
--建立普通使用者 create user 使用者名稱 identified by 密碼(密碼不能以數字開頭)
--剛建立的使用者沒有任何許可權,需要管理員分配相應的許可權
create user jiaozl1 identified by m111111; --- 由於許可權等問題,不能立即使用此賬戶登入
--更改密碼(密碼忘記的情況下可以這樣更改密碼) alter user 使用者名稱 identified by 新密碼;
alter user jiaozl1 identified by m111111;
--建立使用者的細節 預設表空間 臨時表空間 表空間最大使用空間大小3MB
create user jiaozl2 identified by m111111
default tablespace users
temporary tablespace temp
quota 3m on users;
--分配許可權給使用者 grant 許可權 to 使用者名稱;
grant create session to jiaozl2;
————————————————————————————————–
- 許可權主要分為兩種:系統許可權(100多種)和物件許可權。
系統許可權是和資料庫管理相關的許可權:
create session
create table
create index
create view
create sequence
create trriger
......
物件許可權是和使用者操作資料物件相關的許可權:
update table
insert
del
select
2 . 角色分為:預定義角色和自定義角色
預定義角色:把常用的許可權集中起來,形成角色
dba
connect
resource
自定義角色:自己定義的許可權集合
————————————————————————–
create user xiaohong identified by m123
grant connect, resource to xiaohong; -- 分配登入和資源許可權
create table users(id number);
insert into users values(1);
select * from users;
revoke connect from xiaohong; ------
revoke resource from xiaohong; ------ 回收(撤銷)許可權或角色
drop user xiaohong; ---刪除使用者(如果使用者已經建立過資料物件,需要在使用者名稱後加選項cascade,表示將使用者與其建立的物件一併刪除掉)
3 . 方案(Schema)
方案<—->使用者
--scott使用者將許可權分配給xiaohong
grant select on emp to xiaohong;
--執行select時需要指定是哪一個Schema
select * from scott.emp;
---scott將許可權給xiaohong,同時,xiaohong可以將許可權轉給xiaoming
grant select on emp to xiaohong with grant option;
---使用者許可權用:with grant option
---系統許可權用:with admin option