Oracle建立表空間及使用者

2022-04-18 17:08:40 字數 3838 閱讀 8526

1、設定例項名

echo $oracle_sid

export oracle_sid=mvbpbang

2、sqlplus登入/sqlplus命令登入

在安裝oracle時,你需要記住設定的「全域性資料庫名」(預設為orcl) 和 口令,在以兩種方式登入時:

使用者名稱: sys(超級使用者==sysdba) / system(管理員使用者 和sys想比區別在於system不能建立表空間)...

口 令:sqlplus  / as sysdba;

3、建立臨時表空間/表空間/建立使用者/授權

1:建立臨時表空間create temporary tablespace user_temp  

tempfile 'q:\oracle\product\10.2.0\oradata\test\xyrj_temp.dbf'

size 50m

autoextend on

next 50m maxsize 20480m

extent management local;2:建立資料表空間create tablespace user_data

datafile 'q:\oracle\product\10.2.0\oradata\test\xyrj_data.dbf'

size 50m

autoextend on

next 50m maxsizeunlimited

extent management local

segment space management auto;第3步:建立使用者並指定表空間create user username identified by password

default tablespace user_data

temporary tablespace user_temp;第4步:給使用者授予許可權grant connect,resource,dba to username;

刪除user

drop user ×× cascade

說明: 刪除了user,只是刪除了該user下的schema objects,是不會刪除相應的tablespace的。

刪除tablespace

drop  tablespace tablespace_name  including contents and datafiles;

sql code

--刪除空的表空間,但是不包含物理檔案

drop tablespace tablespace_name;

--刪除非空表空間,但是不包含物理檔案

drop tablespace tablespace_name including contents;

--刪除空表空間,包含物理檔案

drop tablespace tablespace_name including datafiles;

--刪除非空表空間,包含物理檔案

drop tablespace tablespace_name including contents and datafiles;

--如果其他表空間中的表有外來鍵等約束關聯到了本表空間中的表的字段,就要加上cascade constraints

drop tablespace tablespace_name including contents and datafiles cascade constraints;

---**---

2、sqlplus登入/sqlplus命令登入

在安裝oracle時,你需要記住設定的「全域性資料庫名」(預設為orcl) 和 口令,在以兩種方式登入時:

使用者名稱: sys(超級使用者==sysdba) / system(管理員使用者 和sys想比區別在於system不能建立表空間)...

口 令:sqlplus  / as sysdba;

3、建立臨時表空間/表空間/建立使用者/授權

1:建立臨時表空間create temporary tablespace user_temp  

tempfile 'q:\oracle\product\10.2.0\oradata\test\xyrj_temp.dbf'

size 50m

autoextend on

next 50m maxsize 20480m

extent management local;2:建立資料表空間create tablespace user_data

datafile 'q:\oracle\product\10.2.0\oradata\test\xyrj_data.dbf'

size 50m

autoextend on

next 50m maxsizeunlimited

extent management local

segment space management auto;第3步:建立使用者並指定表空間create user username identified by password

default tablespace user_data

temporary tablespace user_temp;第4步:給使用者授予許可權grant connect,resource,dba to username;

刪除user

drop user ×× cascade

說明: 刪除了user,只是刪除了該user下的schema objects,是不會刪除相應的tablespace的。

刪除tablespace

drop  tablespace tablespace_name  including contents and datafiles;

sql code

--刪除空的表空間,但是不包含物理檔案

drop tablespace tablespace_name;

--刪除非空表空間,但是不包含物理檔案

drop tablespace tablespace_name including contents;

--刪除空表空間,包含物理檔案

drop tablespace tablespace_name including datafiles;

--刪除非空表空間,包含物理檔案

drop tablespace tablespace_name including contents and datafiles;

--如果其他表空間中的表有外來鍵等約束關聯到了本表空間中的表的字段,就要加上cascade constraints

drop tablespace tablespace_name including contents and datafiles cascade constraints;

---**---

oracle建立表空間及使用者

以system使用者登入後,建立表空間 connect system manager create tablespace 表空間名稱 datafile oracle base oradata oracle sid 資料檔案.dbf size 100m reuse autoextend on next...

oracle建立表空間及使用者

分為四步 第1步 建立臨時表空間 create temporary tablespace user temp tempfile d oracle oradata oracle9i user temp.dbf size 50m autoextend onnext 50m maxsize 20480m ...

Oracle建立使用者及表空間

drop tablespace local temp create temporary tablespace local temp size 32m autoextend on next 32m maxsize 2048m extent management local drop tablespac...