Oracle 建立使用者、資料表空間,及為索引指定資料表空間__Oracle

來源:互聯網
上載者:User

 

----------- 案例一:建立資料表空間及使用者

/*第1步:建立暫存資料表空間 */  
create temporary tablespace IVMS86X0_TEMP    ----測試成功。  註記:資料表空間名字不能重複,即便儲存的位置不一致, 但是dbf檔案可以一致
tempfile 'I:\oracle\oradata\oracle11g\IVMS86X0_TEMP.dbf'
size 50m   ---50m為資料表空間的大小,對大資料量建議用20G,甚至32G
autoextend on
next 50m maxsize 20480m
extent management local;

 

/*第2步:建立資料資料表空間 */
create tablespace IVMS86X0_DATA    ----測試成功。
logging
datafile 'I:\oracle\oradata\oracle11g\IVMS86X0_DATA.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;

/*第3步:建立使用者並指定資料表空間 */
create user IVMS86X0_WJ identified by IVMS86X0_WJ  ---測試成功。
default tablespace IVMS86X0_DATA
temporary tablespace IVMS86X0_TEMP;

/*第4步:給使用者授予許可權 */  
--grant connect,resource to IVMS86X0_WJ;    ---測試成功。

grant connect,resource,dba to IVMS86X0_WJ;  -----建立許可權後,才可以串連  測試成功。


/*刪除資料表空間與使用者*/

drop user IVMS86X0_WJ cascade;  ---刪除使用者的所有對象在刪除使用者   測試成功。
--drop tablespace yuanmin_data including contents;
--drop tablespace yuanmin_temp including contents;


drop tablespace IVMS86X0_DATA including contents and datafiles    -----刪除資料表空間,包括檔案  測試成功。
drop tablespace IVMS86X0_TEMP including contents and datafiles    -----刪除資料表空間,包括檔案  測試成功。

-----刪除使用者資料表空間與刪除使用者,沒有先後之分 測試成功。

----經驗總結。。。
----存在一種情況
--在執行 drop tablespace IVMS86X0_DATA including contents and datafiles時,有使用者在使用,導致drop user IVMS86X0_WJ cascade 無法
--執行,而且此時對應的資料表空間檔案也無法刪除,此時斷開IVMS86X0_WJ使用者,便可手動刪除資料表空間檔案

 


----  案例二:為表索引指定資料表空間

--step0: 建立資料表空間 P201507

create tablespace P201507    ----測試成功。
logging
datafile 'I:\oracle\oradata\oracle11g\P201507.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;

--step2:建立索引,並指定資料表空間

CREATE INDEX idx_vehiclepass_com3
ON traffic_vehicle_pass(plate_no, pass_time, crossing_id) TABLESPACE P201507;  --為索引指定資料表空間

 

 

----- 案例三:oracle資料表空間(資料檔案)滿了後,修改資料表空間的大小

1、擴充資料表空間

alter database datafile 'D:\ORACLE\PRODUCT\ORADATA\TEST\USERS01.DBF' resize 50m;


2、自動成長

alter database datafile 'D:\ORACLE\PRODUCT\ORADATA\TEST\USERS01.DBF' autoextend on next 50m maxsize 500m;

3、增加資料檔案

alter tablespace yourtablespacename add datafile 'd:\newtablespacefile.dbf' size 5m;

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.