手工建立oracle資料庫(轉)

BSDLite發表於2007-08-16
手工建立oracle資料庫(轉)[@more@]系統環境:
1、作業系統:Windows 2000 Server
2、資料庫: Oracle 8i R2 (8.1.6) for NT 企業版/Oracle 9i for NT 企業版
3、安裝路徑:D:ORACLE

步驟:
1、手工建立相關目錄
2、手工建立初始化引數檔案
3、透過oradim建立一個ORACLE服務
4、建立資料庫
5、建立資料庫資料檔案,執行指令碼
6、建立資料字典,執行


手工建立資料庫完整步驟


系統環境
作業系統:Windows 2000 Server
資料庫:Oracle 9i
安裝路徑:C:Oracle
1、手工建立相關目錄
C:Oracleadminweb
C:Oracleadminwebdump
C:Oracleadminwebudump
C:Oracleadminwebcdump
C:Oracleadminwebpfile
C:Oracleadminwebcreate
C:Oracleoradataweb
C:Oracleoradatawebarchive
2、手工建立初始化引數檔案c:oracleadminwebpfileinit.ora,內容可以copy別的例項init.ora檔案後修改。
3、手工建立initweb.ora檔案,內容::ifile= c:oracleadminwebpfileinit.ora
4、使用orapwd.exe命令,建立口令檔案pwdweb.ora,命令格式如下:
orapwd.exe file=c:oracleora90databasepwdweb.ora password=ltjsb entries=5
5、透過oradim.exe命令,在服務裡生成一個新的例項管理服務,啟動方式為手工
set ORACLE_SID=web
C:oracleora90inoradim -new -sid WEB -startmode m
-pfile C:oracleora90databaseinitweb.ora
6、建立資料庫,執行createdb.sql指令碼命令,
SQL>sqlplus /nolog
SQL>connect SYS/change_on_install as SYSDBA
SQL>@Createdb.sql
Createdb.sql指令碼內容如下:
set echo on
spool C:oracleadminmydbcreateCreateDB.log
startup nomount pfile="C:oracleadminwebpfileinit.ora";
CREATE DATABASE web
MAXINSTANCES 1
MAXLOGHISTORY 1
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXDATAFILES 100
DATAFILE 'C:oracleoradatawebsystem01.dbf' SIZE 325M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
UNDO TABLESPACE "UNDOTBS" DATAFILE 'C:oracleoradatawebundotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
LOGFILE GROUP 1 ('C:oracleoradataweb edo01.log') SIZE 100M,
GROUP 2 ('C:oracleoradataweb edo02.log') SIZE 100M,
GROUP 3 ('C:oracleoradataweb edo03.log') SIZE 100M;
spool off
exit;
注:建立資料庫時,執行sql.bsqj指令碼命令,此指令碼命令建立如下內容:
建立控制檔案和聯機日誌檔案
建立資料庫系統表空system
在system表空間上建立system系統回滾段
建立sys和system賬號
建立基表和簇
建立資料字典表、索引和序列
建立相關角色許可權
7、建立資料庫資料檔案,執行指令碼createfiles.sql
SQL>sqlplus /nolog
SQL> connect SYS/change_on_install as SYSDBA
SQL>@createfiles.sql
Createfiles.sql指令碼內容如下:
set echo on
spool C:oracleadminmydbcreateCreateDBFiles.log
CREATE TABLESPACE "INDX" LOGGING DATAFILE 'C:oracleoradatawebindx01.dbf' SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;
CREATE TEMPORARY TABLESPACE "TEMP" TEMPFILE 'C:oracleoradataweb emp01.dbf' SIZE 40M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE "TEMP";
CREATE TABLESPACE "TOOLS" LOGGING DATAFILE 'C:oracleoradataweb ools01.dbf' SIZE 10M REUSE AUTOEXTEND ON NEXT 320K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;
CREATE TABLESPACE "USERS" LOGGING DATAFILE 'C:oracleoradatawebusers01.dbf' SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;
CREATE UNDO TABLESPACE "UNDOTBS" DATAFILE 'C:oracleoradatawebundotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K;
spool off
exit;
8、建立資料字典,執行createdbcatalog.sql指令碼命令
SQL>sqlplus /nolog
SQL> connect SYS/change_on_install as SYSDBA
SQL>@createdbcatalog.sql
Createdbcatalog.sql指令碼內容如下:

set echo on
spool C:oracleadminmydbcreateCreateDBCatalog.log
@C:oracleora90 dbmsadmincatalog.sql;
@C:oracleora90 dbmsadmincatexp7.sql;
@C:oracleora90 dbmsadmincatblock.sql;
@C:oracleora90 dbmsadmincatproc.sql;
@C:oracleora90 dbmsadmincatoctk.sql;
@C:oracleora90 dbmsadmincatobtk.sql;
@C:oracleora90 dbmsadmincaths.sql;
@C:oracleora90 dbmsadminowminst.plb;
connect SYSTEM/manager
@C:oracleora90sqlplusadminpupbld.sql;
connect SYSTEM/manager
set echo on
spool C:oracleora90assistantsdbcalogssqlPlusHelp.log
@C:oracleora90sqlplusadminhelphlpbld.sql helpus.sql;
spool off
spool off
exit;
9、完善資料庫,建立spfile檔案,將資料庫例項啟動服務設定成自動啟動方式。
SQL>sqlplus /nolog
SQL> connect SYS/change_on_install as SYSDBA
SQL> @postdbcreation.sql
Postdbcreation.sql指令碼內容如下:
set echo on
spool C:oracleadminwebcreatepostDBCreation.log
create spfile='C:oracleora90databasespfileweb.ora' FROM pfile='C:oracleadminwebinit.ora';
connect SYS/change_on_install as SYSDBA
set echo on
spool C:oracleora90assistantsdbcalogspostDBCreation.log
shutdown ;
startup ;
注:以上都設定PATH環境變數,將bin目錄加入到PATH中以便於使用工具GMGRLl,sqlplus等。

<!--[if !supportEmptyParas]--&gt <!--[endif]--&gt

==========================================================================================

系統環境:
1、作業系統:Windows 2000 Server,機器記憶體128M
2、資料庫: Oracle 8i R2 (8.1.6) for NT 企業版
3、安裝路徑:D:ORACLE

建庫步驟:
1、手工建立相關目錄
D:Oracleadmin est
D:Oracleadmin estadhoc
D:Oracleadmin estdump
D:Oracleadmin estcdump
D:Oracleadmin estcreate
D:Oracleadmin estexp
D:Oracleadmin estpfile
D:Oracleadmin estudump

D:Oracleoradata est
D:Oracleoradata estarchive

2、手工建立初始化啟動引數檔案:D:Oracleadmin estpfileinittest.ora,內容:

3、手工建立D:OracleOra81DATABASEinittest.ora檔案,

內容:IFILE='D:Oracleadmin estpfileinittest.ora'

4、使用orapwd.exe命令,建立D:OracleOra81DATABASEPWDtest.ora

命令:D:OracleOra81inorapwd file=D:OracleOra81DATABASEPWDtest.ora password=ORACLE entries=5


5、透過oradim.exe命令,在服務裡生成一個新的例項管理服務,啟動方式為手工
set ORACLE_SID=test
D:OracleOra81inoradim -new -sid test -startmode manual -pfile "D:Oracleadmin estpfileinittest.ora"

6、生成各種資料庫物件
D:>svrmgrl

--建立資料庫
connect INTERNAL/oracle
startup nomount pfile="D:Oracleadmin estpfileinittest.ora"
CREATE DATABASE test
LOGFILE 'D:Oracleoradata est edo01.log' SIZE 2048K,
'D:Oracleoradata est edo02.log' SIZE 2048K,
'D:Oracleoradata est edo03.log' SIZE 2048K
MAXLOGFILES 32
MAXLOGMEMBERS 2
MAXLOGHISTORY 1
DATAFILE 'D:Oracleoradata estsystem01.dbf' SIZE 58M REUSE AUTOEXTEND ON NEXT 640K
MAXDATAFILES 254
MAXINSTANCES 1
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET ZHS16GBK;

控制檔案、日誌檔案在上面語句執行時生成


connect INTERNAL/oracle
--修改系統表空間
ALTER TABLESPACE SYSTEM DEFAULT STORAGE ( INITIAL 64K NEXT 64K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 50);
ALTER TABLESPACE SYSTEM MINIMUM EXTENT 64K;

--建立回滾表空間
CREATE TABLESPACE RBS DATAFILE 'D:Oracleoradata est bs01.dbf' SIZE 256M REUSE
AUTOEXTEND ON NEXT 5120K
MINIMUM EXTENT 512K
DEFAULT STORAGE ( INITIAL 512K NEXT 512K MINEXTENTS 8 MAXEXTENTS 4096);

--建立使用者表空間
CREATE TABLESPACE USERS DATAFILE 'D:Oracleoradata estusers01.dbf' SIZE 128M REUSE
AUTOEXTEND ON NEXT 1280K
MINIMUM EXTENT 128K
DEFAULT STORAGE ( INITIAL 128K NEXT 128K MINEXTENTS 1 MAXEXTENTS 4096 PCTINCREASE 0);

--建立臨時表空間
CREATE TABLESPACE TEMP DATAFILE 'D:Oracleoradata est emp01.dbf' SIZE 32M REUSE
AUTOEXTEND ON NEXT 640K
MINIMUM EXTENT 64K
DEFAULT STORAGE ( INITIAL 64K NEXT 64K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0) TEMPORARY;

--建立工具表空間
CREATE TABLESPACE TOOLS DATAFILE 'D:Oracleoradata est ools01.dbf' SIZE 64M REUSE
AUTOEXTEND ON NEXT 320K
MINIMUM EXTENT 32K
DEFAULT STORAGE ( INITIAL 32K NEXT 32K MINEXTENTS 1 MAXEXTENTS 4096 PCTINCREASE 0);

--建立索引表空間
CREATE TABLESPACE INDX DATAFILE 'D:Oracleoradata estindx01.dbf' SIZE 32M REUSE
AUTOEXTEND ON NEXT 1280K
MINIMUM EXTENT 128K
DEFAULT STORAGE ( INITIAL 128K NEXT 128K MINEXTENTS 1 MAXEXTENTS 4096 PCTINCREASE 0);

--建立回滾段
CREATE PUBLIC ROLLBACK SEGMENT RBS0 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS1 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS2 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS3 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS4 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS5 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS6 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS7 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS8 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS9 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS10 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS11 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS12 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS13 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS14 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS15 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS16 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS17 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS18 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS19 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS20 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS21 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS22 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS23 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );
CREATE PUBLIC ROLLBACK SEGMENT RBS24 TABLESPACE RBS STORAGE ( OPTIMAL 4096K );

--使回滾段線上
ALTER ROLLBACK SEGMENT "RBS0" ONLINE;
ALTER ROLLBACK SEGMENT "RBS1" ONLINE;
ALTER ROLLBACK SEGMENT "RBS2" ONLINE;
ALTER ROLLBACK SEGMENT "RBS3" ONLINE;
ALTER ROLLBACK SEGMENT "RBS4" ONLINE;
ALTER ROLLBACK SEGMENT "RBS5" ONLINE;
ALTER ROLLBACK SEGMENT "RBS6" ONLINE;
ALTER ROLLBACK SEGMENT "RBS7" ONLINE;
ALTER ROLLBACK SEGMENT "RBS8" ONLINE;
ALTER ROLLBACK SEGMENT "RBS9" ONLINE;
ALTER ROLLBACK SEGMENT "RBS10" ONLINE;
ALTER ROLLBACK SEGMENT "RBS11" ONLINE;
ALTER ROLLBACK SEGMENT "RBS12" ONLINE;
ALTER ROLLBACK SEGMENT "RBS13" ONLINE;
ALTER ROLLBACK SEGMENT "RBS14" ONLINE;
ALTER ROLLBACK SEGMENT "RBS15" ONLINE;
ALTER ROLLBACK SEGMENT "RBS16" ONLINE;
ALTER ROLLBACK SEGMENT "RBS17" ONLINE;
ALTER ROLLBACK SEGMENT "RBS18" ONLINE;
ALTER ROLLBACK SEGMENT "RBS19" ONLINE;
ALTER ROLLBACK SEGMENT "RBS20" ONLINE;
ALTER ROLLBACK SEGMENT "RBS21" ONLINE;
ALTER ROLLBACK SEGMENT "RBS22" ONLINE;
ALTER ROLLBACK SEGMENT "RBS23" ONLINE;
ALTER ROLLBACK SEGMENT "RBS24" ONLINE;

--修改sys使用者的臨時表空間為TEMP
alter user sys temporary tablespace TEMP;

--建立資料字典表
@D:OracleOra81Rdbmsadmincatalog.sql;
@D:OracleOra81Rdbmsadmincatexp7.sql
@D:OracleOra81Rdbmsadmincatproc.sql
@D:OracleOra81Rdbmsadmincaths.sql

connect system/manager
@D:OracleOra81sqlplusadminpupbld.sql

connect internal/oracle
@D:OracleOra81Rdbmsadmincatrep.sql
exit

--生成SQL*Plus幫助系統
sqlplus SYSTEM/manager
@D:OracleOra81sqlplusadminhelphelpbld.sql helpus.sql
exit

--修改system使用者預設表空間和臨時表空間
svrmgrl
connect internal/oracle
alter user system default tablespace TOOLS;
alter user system temporary tablespace TEMP;
exit

7、將test例項啟動服務設定成自動啟動方式
D:OracleOra81inoradim -edit -sid test -startmode auto

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10617542/viewspace-961500/,如需轉載,請註明出處,否則將追究法律責任。

相關文章