Oracle創(chuàng)建用戶(hù)與表空間的絕對(duì)干貨(建議收藏)
Oracle-創(chuàng)建用戶(hù)
查看表空間
select tablespace_name, file_id, file_name, round(bytes/(1024*1024),0) total_space_MB from dba_data_files order by tablespace_name;
Oracle 創(chuàng)建表空間
create tablespace 表空間名字 --空間名 datafile "數(shù)據(jù)存儲(chǔ)路徑\***.dbf" --路徑 size 5M --初始大小 autoextend on next 5M --表空間每次增長(zhǎng)大小 maxsize 3000M --表空間最大內(nèi)存
Oracle 修改表空間大小
alter database datafile "E:\DATA\ORACLE\.DBF" resize 20480m
—創(chuàng)建用戶(hù)
create user "****" identified by xyx2021 default tablespace "****";
—用戶(hù)授權(quán)
grant connect, resource to "***"; grant create session to "***";
—修改用戶(hù)BEE表空間
Alter user BEE default tablespace BEE
–刪除表空間
drop tablespace fish;
總結(jié)
Oracle安裝完后,其中有一個(gè)缺省的數(shù)據(jù)庫(kù),除了這個(gè)缺省的數(shù)據(jù)庫(kù)外,我們還可以創(chuàng)建自己的數(shù)據(jù)庫(kù)。
為了避免麻煩,可以用’Database Configuration Assistant’向?qū)?lái)創(chuàng)建數(shù)據(jù)庫(kù)(這步一定要?jiǎng)?chuàng)建好,因?yàn)檫@里沒(méi)有做好,會(huì)在創(chuàng)建表空間時(shí)出錯(cuò)—我就在這里花了幾個(gè)小時(shí),暈)。
創(chuàng)建完數(shù)據(jù)庫(kù)后,并不能立即在數(shù)據(jù)庫(kù)中建表,必須先創(chuàng)建該數(shù)據(jù)庫(kù)的用戶(hù),并且為該用戶(hù)指定表空間。
下面是創(chuàng)建數(shù)據(jù)庫(kù)用戶(hù)的具體過(guò)程:
1.假如現(xiàn)在已經(jīng)建好名為’test’的數(shù)據(jù)庫(kù),此時(shí)在d:\oracle\oradata\目錄下已經(jīng)存在test目錄(注意:我的Oracle11g安裝在d:\oracle下,若你的Oracle安裝在別的目錄,那么你新建的數(shù)據(jù)庫(kù)目錄就在*\oradata\目錄下)。
2.在創(chuàng)建用戶(hù)之前,先要?jiǎng)?chuàng)建表空間:
其格式為:格式: create tablespace 表間名 datafile ‘數(shù)據(jù)文件名’ size 表空間大小;
如: SQL> create tablespace test_tablespace datafile ‘d:\oracle\oradata\test\test.dbf’ size 100M;
其中’test_tablespace’是你自定義的表空間名稱(chēng),可以任意取名;
‘d:\oracle\oradata\test\test.dbf’是數(shù)據(jù)文件的存放位置,’test.dbf’文件名也是任意取;
‘size 100M’是指定該數(shù)據(jù)文件的大小,也就是表空間的大小。
刪除命名空間
DROP TABLESPACE test INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS;
3.現(xiàn)在建好了名為’test_tablespace’的表空間,下面就可以創(chuàng)建用戶(hù)了:
其格式為:格式: create user 用戶(hù) 名 identified by 密碼 default tablespace 表空間表;
如: SQL> create user testone identified by testone default tablespace test_tablespace;
默認(rèn)表空間’default tablespace’使用上面創(chuàng)建的表空間。
4.接著授權(quán)給新建的用戶(hù):
SQL> grant connect,resource to testone; –表示把 connect,resource權(quán)限授予testone用戶(hù)
SQL> grant dba to testone; –表示把 dba權(quán)限授予給testone用戶(hù) 授權(quán)成功。
ok! 數(shù)據(jù)庫(kù)用戶(hù)創(chuàng)建完成,現(xiàn)在你就可以使用該用戶(hù)創(chuàng)建數(shù)據(jù)表了!
到此這篇關(guān)于oracle創(chuàng)建用戶(hù)過(guò)程詳解的文章就介紹到這了,更多相關(guān)oracle創(chuàng)建用戶(hù)內(nèi)容后續(xù)有時(shí)間會(huì)陸續(xù)更新,以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,初來(lái)乍到希望大家以后多多支持
