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

2021-09-02 20:31:14 字數 2400 閱讀 7384

--表空間

建立表空間(一般建n個存資料的表空間和乙個索引空間):

create tablespace 表空間名

datafile ' 路徑(要先建好路徑)\***.dbf ' size *m

tempfile ' 路徑\***.dbf ' size *m

autoextend on --自動增長

--還有一些定義大小的命令,看需要

default storage(

initial 100k,

next 100k,

); create tablespace sdt

datafile 'f:\tablespace\demo' size 800m

extent management local segment space management auto;

--索引表空間

create tablespace sdt_index

datafile 'f:\tablespace\demo' size 512m

extent management local segment space management auto;

--2.建使用者

建立:create user 使用者名稱 identified by "密碼";

create user demo identified by demo

default tablespace std;

--3.賦權

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

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

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

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

grant drop any table to sun; //授予刪除表的許可權

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

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

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

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

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

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

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

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

grant insert(id) on tablename to sun;

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

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

撤銷許可權

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

檢視許可權

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

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

許可權傳遞

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

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

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

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

create role myrole;//建立角色

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

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

drop role myrole;刪除角色

--匯入匯出命令

ip匯出方式: exp demo/[email protected]:1521/orcl file=f:/f.dmp full=y

exp demo/demo@orcl file=f:/f.dmp full=y

imp demo/demo@orcl file=f:/f.dmp full=y ignore=y

Oracle 建立表空間,建立使用者,使用者賦權

注意點 1.如果在pl sql 等工具裡開啟的話,直接修改下面的 中 斜體加粗部分 執行 2.確保路徑存在,比如 c oracle oradata oracle11 也就是你要儲存檔案的路徑存在 3.以下語句必須為dba許可權的使用者才可以執行成功。分為四步 第1步 建立臨時表空間 create t...

oracle 建立使用者表空間及賦權

最近在使用資料庫經常建立使用者表空間 再次記錄一下 第一步 建立資料表空間 create tablespace logging datafile u02 oradata orcl dbf size 10m autoextend on next 10m maxsize unlimited extent...

oracle 建立表空間 使用者 賦權 建表

一 建立表空間 1.建立臨時表空間 create temporary tablespace ts tem tab space tempfile d oracle ts tem tab space.dbf size 50m autoextend on next 50m maxsize 20480m e...