深入講述Oracle 9i創(chuàng)建表空間
作者:佚名
在向大家詳細(xì)介紹Oracle 9i建庫之前,首先讓大家了解下Oracle是如何創(chuàng)建表空間的,希望對大家有用。
下面是有關(guān)Oracle 9i創(chuàng)建表空間,用戶,授權(quán),角色.常用的SQL語句,用sys帳號登陸,連接身份選SYSDBA,執(zhí)行如下語句
// 創(chuàng)建表空間
drop tablespace test;
create tablespace test
DATAFILE 'D:\oracle\oradata\test\test.dbf'
size 10M AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED;
alter user scott quota unlimited on test;
commit; 創(chuàng)建了一個名為test的表空間,數(shù)據(jù)庫文件創(chuàng)建 在D:\oracle\oradata\test\test.dbf,并給scott 帳號授權(quán)使用表空間。 //創(chuàng)建scott用戶 并分配表空間
drop user scott cascade;
create user scott
identified by tiger
default tablespace test
quota 100M on test;
commit; //創(chuàng)建完畢后授權(quán)
Grant connect,resource,create session,create table,create sequence,create any view,EXP_FULL_DATABASE, IMP_FULL_DATABASE, DBA,to scott; //sql plus 中執(zhí)行.sql 文件
@d:\xzsp_hrb_oracle_doc.sql //創(chuàng)建一個名為manager的角色
create role manager; //給manager這個角色授于相應(yīng)的系統(tǒng)權(quán)限
grant create table,create view,create session to manager; //授予針對某個對象的權(quán)限如查詢某個表的權(quán)限
grant select on 表名字 to manager; //可以把一個權(quán)限同時賦予多個角色或者用戶,但不能把多個權(quán)限同時賦予多個角色或者用戶,需分開執(zhí)行。 //把manager這個角色分配給scott,xzsp兩個帳號。
grant manager to scott,xzsp; //修改帳號scott密碼為tiger
alert user scott identified by tiger; //scott用戶建的表,如果想給其他用戶權(quán)限則必須用scott用戶登陸后執(zhí)行如下語句,即使你是DBA也不把 一個用戶(scott)所創(chuàng)建的表賦予給另外一個用戶(xzsp)操作的權(quán)限,除非scott用戶給DBA授權(quán)。
grant select on 表名字 to xzsp;
grant select on employees to scott,xzsp; //用scott用戶登陸 給system授權(quán)
grant select on student to system with grant option; //用system 登陸,再把查詢student的權(quán)限授予另外一個用戶。
grant select on scott.student to xzsp; //system同時可取消xzsp用戶的該權(quán)限。
revoke select on scott.student from xzsp; 權(quán)限傳遞的級聯(lián):scott用戶把權(quán)限給A(同時允許A傳遞給其他用戶 with grand option),A把權(quán)限再傳遞給B,如果scott用戶撤消A的權(quán)限,則B也會失去相應(yīng)的權(quán)限。 grant update (department_name,location_id) on departments to scott,xzsp; //授予用戶修改某個表中指定字段的權(quán)限。 grant select,insert on departments to scott with grant option; //把查詢,增加departments表的權(quán)限給scott用戶并允許他把權(quán)限授予給其他擁護(hù)。 grant select on scott.departments to public; //授予public 角色查詢scott下departments表的權(quán)限。 //訪問其他數(shù)據(jù)庫對象(database links)
create public database link hq.acme.com using 'sales';
select * from emp@hq.acme.com //emp為表名
CREATE USER 創(chuàng)建一個用戶(通常由DBA來完成)。
GRANT 給于其他用戶使用你自己對象的權(quán)限。
CREATE ROLE 創(chuàng)建一個權(quán)限的集合,即角色。
ALTER USER 修改一個用戶的密碼。
REVOKE 撤消一個用戶在某個對象上的權(quán)限,如 表 視圖等。 ----------------------查看用戶權(quán)限-----------------------------------
--------------------------------------------------------------------------
1.查看所有用戶:
select * from dba_users;
select * from all_users;
select * from user_users; 2.查看用戶或角色系統(tǒng)權(quán)限:
select * from dba_sys_privs;
select * from user_sys_privs; 3.查看用戶對象權(quán)限:
select * from dba_tab_privs;
select * from all_tab_privs;
select * from user_tab_privs; 4.查看所有角色:
select * from dba_roles; 5.查看用戶或角色所擁有的角色:
select * from dba_role_privs;
select * from user_role_privs;
drop tablespace test;
create tablespace test
DATAFILE 'D:\oracle\oradata\test\test.dbf'
size 10M AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED;
alter user scott quota unlimited on test;
commit; 創(chuàng)建了一個名為test的表空間,數(shù)據(jù)庫文件創(chuàng)建 在D:\oracle\oradata\test\test.dbf,并給scott 帳號授權(quán)使用表空間。 //創(chuàng)建scott用戶 并分配表空間
drop user scott cascade;
create user scott
identified by tiger
default tablespace test
quota 100M on test;
commit; //創(chuàng)建完畢后授權(quán)
Grant connect,resource,create session,create table,create sequence,create any view,EXP_FULL_DATABASE, IMP_FULL_DATABASE, DBA,to scott; //sql plus 中執(zhí)行.sql 文件
@d:\xzsp_hrb_oracle_doc.sql //創(chuàng)建一個名為manager的角色
create role manager; //給manager這個角色授于相應(yīng)的系統(tǒng)權(quán)限
grant create table,create view,create session to manager; //授予針對某個對象的權(quán)限如查詢某個表的權(quán)限
grant select on 表名字 to manager; //可以把一個權(quán)限同時賦予多個角色或者用戶,但不能把多個權(quán)限同時賦予多個角色或者用戶,需分開執(zhí)行。 //把manager這個角色分配給scott,xzsp兩個帳號。
grant manager to scott,xzsp; //修改帳號scott密碼為tiger
alert user scott identified by tiger; //scott用戶建的表,如果想給其他用戶權(quán)限則必須用scott用戶登陸后執(zhí)行如下語句,即使你是DBA也不把 一個用戶(scott)所創(chuàng)建的表賦予給另外一個用戶(xzsp)操作的權(quán)限,除非scott用戶給DBA授權(quán)。
grant select on 表名字 to xzsp;
grant select on employees to scott,xzsp; //用scott用戶登陸 給system授權(quán)
grant select on student to system with grant option; //用system 登陸,再把查詢student的權(quán)限授予另外一個用戶。
grant select on scott.student to xzsp; //system同時可取消xzsp用戶的該權(quán)限。
revoke select on scott.student from xzsp; 權(quán)限傳遞的級聯(lián):scott用戶把權(quán)限給A(同時允許A傳遞給其他用戶 with grand option),A把權(quán)限再傳遞給B,如果scott用戶撤消A的權(quán)限,則B也會失去相應(yīng)的權(quán)限。 grant update (department_name,location_id) on departments to scott,xzsp; //授予用戶修改某個表中指定字段的權(quán)限。 grant select,insert on departments to scott with grant option; //把查詢,增加departments表的權(quán)限給scott用戶并允許他把權(quán)限授予給其他擁護(hù)。 grant select on scott.departments to public; //授予public 角色查詢scott下departments表的權(quán)限。 //訪問其他數(shù)據(jù)庫對象(database links)
create public database link hq.acme.com using 'sales';
select * from emp@hq.acme.com //emp為表名
CREATE USER 創(chuàng)建一個用戶(通常由DBA來完成)。
GRANT 給于其他用戶使用你自己對象的權(quán)限。
CREATE ROLE 創(chuàng)建一個權(quán)限的集合,即角色。
ALTER USER 修改一個用戶的密碼。
REVOKE 撤消一個用戶在某個對象上的權(quán)限,如 表 視圖等。 ----------------------查看用戶權(quán)限-----------------------------------
--------------------------------------------------------------------------
1.查看所有用戶:
select * from dba_users;
select * from all_users;
select * from user_users; 2.查看用戶或角色系統(tǒng)權(quán)限:
select * from dba_sys_privs;
select * from user_sys_privs; 3.查看用戶對象權(quán)限:
select * from dba_tab_privs;
select * from all_tab_privs;
select * from user_tab_privs; 4.查看所有角色:
select * from dba_roles; 5.查看用戶或角色所擁有的角色:
select * from dba_role_privs;
select * from user_role_privs;
【編輯推薦】
責(zé)任編輯:佚名