Oracle 11.2命令列手工最簡建立資料庫的過程
命令列手工最簡建立資料庫的過程
環境:RHEL 5.4 x86 , oracle 11.2
1.設定環境變數
在/home/oracle編輯
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
# 11g R2
export ORACLE_HOME=/app/oracle/product/11.2.0/dbhome_1
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export NLS_LANG=AMERICAN_AMERICA.UTF8
export ORACLE_SID=orcl
umask 022
2.禁用SELinux
如果在安裝RHEL的時候啟用了SELinux,需要
以root使用者setenforce 0
否則會出現:sqlplus: error while loading shared libraries
3.以oracle使用者登入編輯init.ora
只要1行
db_name=orcl
4.登入sqlplus / as sysdba
create spfile='spfileorcl.ora' from pfile='/home/oracle/init.ora'
startup nomount
create database orcl;
等候建立資料庫成功。
select sysdate from dual;
已經可以查出日期。
5.執行指令碼建立系統檢視表和包
@?/rdbms/admin/catalog
@?/rdbms/admin/catproc
以system使用者執行
@?/sqlplus/admin/pupbld
此時可以看到v$datafile和v$controlfile
位於$ORACLE_HOME/dbs,檔案名稱分別是dbs1orcl dbx1orcl dbu1orcl cntrlorcl
幾點疑問:
1.文檔上說至少pfile需要3個參數,其他都有預設值,而我唯寫了1個,也可以。
2.建立資料庫的資料表空間只有system sysaux sys_undots,沒有暫存資料表空間,資料庫運行也不出錯
不知道是否這也是oracle 11.2的新特性?
3.曾經在一個.sql檔案中寫了如下的語句,但沒有執行成功
create database orcl
user sys identified by sys
user system identified by sys
extent management local
default temporary tablespace temp
undo tablespace undotbs1
default tablespace users;
4.文檔中沒有說需要system使用者執行pupbld,我用sys使用者執行
結果在建立使用者oo登入時提示error accessing PRODUCT_USER_PROFILE
參考資料http://download.oracle.com/docs/ ... 10595/create003.htm