用戶管理 操作過程:Users->右鍵new...建用戶 用戶名和密碼: 設置許可權 1.新增用戶 -- Create the user -- tablespace表空間指數據存儲的位置 基本語法:SQL>create user 用戶名 identified by 密碼; create user st ...
用戶管理
操作過程:Users->右鍵new...建用戶
用戶名和密碼:
設置許可權
1.新增用戶
-- Create the user
-- tablespace表空間指數據存儲的位置
基本語法:SQL>create user 用戶名 identified by 密碼;
create user student identified by "123456" default tablespace USERS
temporary tablespace TEMP;
2.用戶授權
此時用戶還不能登陸,要給用戶授權才可以登陸
基本語法:SQL>grant 許可權名 to 用戶名;
例如授予tom用戶登錄許可權
SQL>grant create session to tom;
create session是登錄許可權
create table 創建表的許可權
-- oracle用戶必須擁有session會話許可權才能登錄資料庫
-- 用戶的許可權分3種:對象許可權,角色許可權,系統許可權
--常用的開發賬號許可權:
--connect和resource是兩個系統內置的角色
grant connect to STUDENT;
grant resource to STUDENT;
grant unlimited tablespace to STUDENT;
1)DBA:擁有全部特權,是系統最高許可權,只有DBA才可以創建資料庫結構。
2)RESOURCE:擁有Resource許可權的用戶只可以創建實體,不可以創建資料庫結構。
3)CONNECT:擁有Connect許可權的用戶只可以登錄Oracle,不可以創建實體,不可以創資料庫結構。
4)對於普通用戶:授予connect, resource許可權。
5)對於DBA管理用戶:授予connect,resource, dba許可權。
6)且系統許可權只能由DBA用戶授出:sys, system(最開始只能是這兩個用戶)。普通用戶通過授權可以具有與system相同的用戶許可權,
3.回收許可權
取消用戶的授權採用remove命令
語法:revoke許可權名 from 用戶名;
例如:SQL>revoke create table from tom;
4.修改用戶
-- Modify the user
alter user STUDENT identified by "123456"; -- 修改密碼
alter user STUDENT account lock; -- 鎖定賬號
alter user STUDENT account unlock; -- 解鎖賬號
5.刪除用戶
drop user student;
補充:
-- 查詢系統的所有用戶,dba_users是系統表;保存了所有用戶的賬號
select * from dba_users;