程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> 如何手動創建oracle數據庫

如何手動創建oracle數據庫

編輯:Oracle教程

下面的實驗室是如何不要通過DBCA創建ORACLE 數據庫,而是通過ORACLE ONLINE HELP DOCUMENT進行手動的創建數據庫的詳細步驟:

1,編輯Oracle profile
[root@vmoel5u4 ~]# su - oracle
[oracle@vmoel5u4 ~]$ vi ./.bash_profile
PATH=$PATH:$HOME/bin

export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=PROD
export PATH=$ORACLE_HOME/jdk/bin:$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib

2,創建相應的ORACLE數據文件的目錄
[oracle@vmoel5u4 ~]$ mkdir -p /u01/app/oracle/oradata/PROD/DISK1
[oracle@vmoel5u4 ~]$ mkdir -p /u01/app/oracle/oradata/PROD/DISK2
[oracle@vmoel5u4 ~]$ mkdir -p /u01/app/oracle/oradata/PROD/DISK3
[oracle@vmoel5u4 ~]$ mkdir -p /u01/app/oracle/admin/PROD/{a,b,c,u,dp}dump

3,創建ORACLE數據庫的密碼文件
[oracle@vmoel5u4 ~]$ cd $ORACLE_HOME/dbs
[oracle@vmoel5u4 dbs]$ ll
total 28
-rw-r----- 1 oracle oinstall 12920 May 3 2001 initdw.ora
-rw-r----- 1 oracle oinstall 8385 Sep 11 1998 init.ora
[oracle@vmoel5u4 dbs]$ orapwd
Usage: orapwd file=<fname> password=<password> entries=<users> force=<y/n>

where
file - name of password file (mand),
password - password for SYS (mand),
entries - maximum number of distinct DBA and force - whether to overwrite existing file (opt),
OPERs (opt),
There are no spaces around the equal-to (=) character.
[oracle@vmoel5u4 dbs]$ orapwd file=orapwPROD password=oracle entries=5 force=y;
[oracle@vmoel5u4 dbs]$ ll
total 32
-rw-r----- 1 oracle oinstall 12920 May 3 2001 initdw.ora
-rw-r----- 1 oracle oinstall 8385 Sep 11 1998 init.ora
-rw-r----- 1 oracle oinstall 2048 Nov 25 20:45 orapwPROD

4,創建啟動數據庫的參數文件
[oracle@vmoel5u4 dbs]$ vi initPROD.ora
db_block_size=8192
db_name=PROD
control_files=('/u01/app/oracle/oradata/PROD/DISK1/control01.ctl','/u01/app/oracle/oradata/PROD/DISK2/control02.ctl')
compatible=10.2.0.1.0
processes=150
pga_aggregate_target=90m
UNDO_TABLESPACE=UNDOTBS
undo_management=AUTO
sga_target=300m

5,在幫助文檔裡查找手動創建數據庫的腳本,並做相應的修改。

[oracle@vmoel5u4 dbs]$ vi createDB.sql
CREATE DATABASE PROD
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/PROD/DISK1/redo01a.log','/u01/app/oracle/oradata/PROD/DISK2/redo01b.log') SIZE

100M,
GROUP 2 ('/u01/app/oracle/oradata/PROD/DISK1/redo02a.log','/u01/app/oracle/oradata/PROD/DISK2/redo02b.log') SIZE

100M,
GROUP 3 ('/u01/app/oracle/oradata/PROD/DISK1/redo03a.log','/u01/app/oracle/oradata/PROD/DISK2/redo03b.log') SIZE

100M
MAXLOGFILES 15
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
DATAFILE '/u01/app/oracle/oradata/PROD/DISK1/system01.dbf' SIZE 325M REUSE
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/u01/app/oracle/oradata/PROD/DISK1/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TEMPORARY TABLESPACE TEMP
TEMPFILE '/u01/app/oracle/oradata/PROD/DISK1/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE UNDOTBS
DATAFILE '/u01/app/oracle/oradata/PROD/DISK1/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;


6,把數據庫啟動到nomount狀態下進行創建數據庫
[oracle@vmoel5u4 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Nov 25 21:06:32 2012

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 314572800 bytes
Fixed Size 1219160 bytes
Variable Size 96470440 bytes
Database Buffers 213909504 bytes
Redo Buffers 2973696 bytes
SQL> @createDB.sql

Database created.


7,運行相應的數據庫的基礎腳本
下面的5個腳本是在sys schema下執行的:
創建數據字典視圖
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catalog.sql;(必須先執行它,才可以執行catproc.sql)
創建ORACLE中一些鎖機制相關的視圖
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catblock.sql;
創建ORACLE一些存儲過程和包
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catproc.sql;
創建需要使用PL/ SQL加密工具的接口
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catoctk.sql;
安裝SQL*Plus的表PRODUCT_USER_PROFILE, 好像是與數據倉庫有關的東西.
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/owminst.plb;

下面的2個腳本是在system schema下執行的。
connect system/oracle
@/u01/app/oracle/product/10.2.0/db_1/sqlplus/admin/pupbld.sql;
connect system/oracle
@/u01/app/oracle/product/10.2.0/db_1/sqlplus/admin/help/hlpbld.sql helpus.sql;


8,創建spfile文件
SQL> conn / as sysdba
Connected.
SQL> create spfile from pfile;

File created.


9,關閉數據庫,重新用spfile啟動數據庫
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 314572800 bytes
Fixed Size 1219160 bytes
Variable Size 96470440 bytes
Database Buffers 213909504 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.

到此手動創建數據庫成功!

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved