Oracle 建立使用者,臨時表空間,表空間,授權

2021-07-30 04:53:20 字數 2290 閱讀 8689

建立使用者需要制訂預設表空間及臨時表空間,如果忽略,system表空間將成為預設表空間,這樣並不好。

所以我們在建立使用者之前,先建立表空間。

首先使用sys賬號使用sysbda方式登陸

--建立臨時表空間

create temporary tablespace mydataspace_temp

tempfile 'd:\oracle\oradata\orcl\mydataspace_temp.dbf'

size 200m

autoextend on

next 100m maxsize 20480m

extent management local;

--建立表空間

create tablespace mydataspace_data

logging

datafile 'd:\oracle\oradata\orcl\mydataspace.dbf'

size 500m

autoextend on

next 200m maxsize 20480m

extent management local;

--建立使用者並且設定預設表空間和臨時表空間

create user qiudong identified by qd1234

default tablespace mydataspace_data

temporary tablespace mydataspace_temp;

--使用者解鎖

alter user qiudong account unlock;

--設定許可權

grant connect, resource to qiudong;

--刪除使用者

drop user qiudong;

1. connect role(連線角色) 

臨時使用者,特別是那些不需要建表的使用者,通常只賦予他們connectrole。connect是使用oracle的簡單許可權,這種許可權只有在對其他使用者的表有訪問權時,包括select、insert、update和delete等,才會變得有意義。擁有connect role的使用者還能夠建立表、檢視、序列(sequence)、簇(cluster)、同義詞(synonym )、會話(session)和與其他資料庫的鏈(link)。 

2. resource role(資源角色) 

更可靠和正式的資料庫使用者可以授予resource role。resource提供給使用者另外的許可權以建立他們自己的表、序列、過程(procedure)、觸發器(trigger)、索引(index)和簇(cluster)。 

3. dba role(資料庫管理員角色) 

dba role擁有所有的系統許可權----包括無限制的空間限額和給其他使用者授予各種許可權的能力。system由dba使用者擁有。下面介紹一些dba經常使用的典型許可權。 

grant(授權)命令 

下面對剛才建立的使用者user01授權,命令如下: 

grant connect, resource to user01; 

revoke(撤消)許可權 

已授予的許可權可以撤消。例如撤消(1)中的授權,命令如下: 

revoke connect, resource from user01; 

除了前面講到的三種系統角色----connect、resource和dba,使用者還可以在oracle建立自己的role。使用者建立的role可以由表或系統許可權或兩者的組合構成。為了建立role,使用者必須具有create role系統許可權。下面給出乙個create role命令的例項: 

create role student; 

這條命令建立了乙個名為student的role。 

一旦建立了乙個role,使用者就可以給他授權。給role授權的grant命令的語法與對對使用者的語法相同。在給role授權時,在grant命令的to子句中要使用role的名稱,如下所示: 

grant select on class to student; 

現在,擁有student 角色的所有使用者都具有對class 表的select許可權。

要刪除角色,可以使用drop role命令,如下所示: 

drop role student; 

在刪除乙個表中的全部資料時,須使用 

truncate table 表名

因為用drop table,delete * from 表名時,tablespace表空間該錶的占用空間並未釋放,反覆幾次drop,delete操作後,該tablespace上百兆的空間就被耗光了。 

oracle 建立使用者 建立臨時表空間 賦予許可權

建立臨時表空間,如果已經有,就不需要建立 create temporary tablespace tempts01 tempfile c oracle product 10.2.0 oradata orcl tempts01.dbf size 100m 建立使用者 create user xuebi...

建立表空間 臨時表空間 使用者 指定表空間

1 刪除已有的舊資料 表空間和臨時表空間下 drop tablespace user data including contents and datafiles drop tablespace user temp including contents and datafiles 2 建立表空間 建立...

oracle建立表空間,建立使用者

建立臨時表空間 create temporary tablespace test temp tempfile e oracle product 10.2.0 oradata testserver test temp01.dbf size 32m autoextend on next 32m maxs...