建立表空間

2021-08-20 01:52:04 字數 1431 閱讀 4168

create tablespace my_data01 datafile 'd:\sqloracle\mytest\test001.dbf' size 500m;

create user limihe identified by 123456 default tablespace my_data01;

grant connect,dba,resource to limihe;

oracle安裝完後,其中有乙個預設的資料庫,除了這個預設的資料庫外,我們還可以建立自己的資料庫。

對於初學者來說,為了避免麻煩,可以用'database configuration assistant'嚮導來建立資料庫。

建立完資料庫後,並不能立即在資料庫中建表,必須先建立該資料庫的使用者,並且為該使用者指定表空間。

下面是建立資料庫使用者的具體過程:

1.假如現在已經建好名為'news'的資料庫,此時在f:\oracle\product\10.1.0\oradata\目錄下已經存在news目錄(注意:我的oracle10g安裝在f:\oracle下,若你的oracle安裝在別的目錄,那麼你新建的資料庫目錄就在*\product\10.1.0\oradata\目錄下)。

2.在建立使用者之前,先要建立表空間:

其格式為:格式: create tablespace 表間名 datafile '資料檔名' size 表空間大小;

如:sql> create tablespace news_tablespace datafile 'f:\oracle\product\10.1.0\oradata\news\news_data.dbf' size 500m;

注意:這個路徑是自己安裝oracle的路徑,必須先建立news資料夾,否則會報錯!

其中'news_tablespace'是你自定義的表空間名稱,可以任意取名;'f:\oracle\product\10.1.0\oradata\news\news_data.dbf'是資料檔案的存放位置,'news_data.dbf'檔名也是任意取;'size 500m'是指定該資料檔案的大小,也就是表空間的大小。

3.現在建好了名為'news_tablespace'的表空間,下面就可以建立使用者了:

其格式為:格式: create user 使用者名稱 identified by 密碼 default tablespace 表空間表;

如:sql> create user news identified by news default tablespace news_tablespace;

預設表空間'default tablespace'使用上面建立的表空間。

4.接著授權給新建的使用者:

sql> grant connect,resource to news; --表示把 connect,resource許可權授予news使用者

sql> grant dba to news; --表示把 dba許可權授予給news使用者

授權成功。

建立表空間

建立臨時表空間 create temporary tablespace test temp size 32m autoextend on next 32m maxsize 2048m extent management local 建立資料表空間 create tablespace test log...

建立表空間

1 建立表空間 create tablespace yyy nologging datafile c yyy.dbf size 50m autoextend on next 50m maxsize 1024m extent management local datafile 是關鍵字,用於指定資料檔...

建立表空間

oracle10g 在plsql developer上建立表空間指令碼 建立表空間 create tablespace mof temp datafile d oracle product 10.2.0 oradata orcl mof temp.def size 500m autoextend o...