oracle建库是个常用的功能,大多数人都会,这里发出希望能对初学者有用!
下面是
oracle建库常用步骤:
DBCA生成脚本,数据库版本9.2.0.7.0,系统:WINDOWS2003 SP2
脚本路径:D:oracleadminlectscripts
建库脚本:lect.bat
1 创建目录
mkdir D:oracleadminlectbdump
mkdir D:oracleadminlectcdump
mkdir D:oracleadminlectcreate
mkdir D:oracleadminlectpfile
mkdir D:oracleadminlectudump
mkdir D:oracleora92database
mkdir D:oracleoradatalect
2 设置IBID
set ORACLE_SID=lect
3 创建系统服务
D:oracleora92binoradim.exe -new -sid lect -startmode a
4 创建密码文件PWDlect.ora
D:oracleora92binorapwd.exe file=D:oracleora92databasePWDle
ct.ora password=change_on_install
5 执行脚本CreateDB.sql创建数据库
5.1 以默认密码change_on_install登录
connect SYS/change_on_install as SYSDBA
5.2 设置输出CreateDB.log
set echo on
spool D:oracleora92assistantsdbcalogsCreateDB.log
5.3 根据init.ora这个pfile文件NOMOUNT数据库
startup nomount pfile="D:oracleadminlectscriptsinit.ora";
5.4 执行建库脚本创建数据库
CREATE DATABASE lect
MAXINSTANCES 1
MAXLOGHISTORY 1
MAXLOGFILES 5
MAXLOGMEMBERS 3
MAXDATAFILES 100
DATAFILE 'D:oracleoradatalectsystem01.dbf' SIZE 250M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL
DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE 'D:oracleoradatalecttemp01.dbf' SIZE 40M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
UNDO TABLESPACE "UNDOTBS1" DATAFILE 'D:oracleoradatalectundotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
LOGFILE GROUP 1 ('D:oracleoradatalectredo01.log') SIZE 102400K,
GROUP 2 ('D:oracleoradatalectredo02.log') SIZE 102400K,
GROUP 3 ('D:oracleoradatalectredo03.log') SIZE 102400K;
6 执行脚本CreateDBFiles.sql创建数文件
6.1 以SYS用户登录
connect SYS/change_on_install as SYSDBA
6.2 设置输出CreateDBFiles.log
set echo on
spool D:oracleora92assistantsdbcalogsCreateDBFiles.log
6.3 执行建立数据文件脚本
CREATE TABLESPACE "DRSYS" LOGGING DATAFILE 'D:oracleoradatalectdrsys01.dbf' SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;
CREATE TABLESPACE "INDX" LOGGING DATAFILE 'D:oracleoradatalectindx01.dbf' SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;
CREATE TABLESPACE "TOOLS" LOGGING DATAFILE 'D:oracleoradatalecttools01.dbf' SIZE 10M REUSE AUTOEXTEND ON NEXT 320K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;
CREATE TABLESPACE "USERS" LOGGING DATAFILE 'D:oracleoradatalectusers01.dbf' SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;
CREATE TABLESPACE "XDB" LOGGING DATAFILE 'D:oracleoradatalectxdb01.dbf' SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;
7 执行脚本CreateDBCatalog.sql
7.1 以SYS用户登录
connect SYS/change_on_install as SYSDBA
7.2 设置输出CreateDBFiles.log
set echo on
spool D:oracleora92assistantsdbcalogs CreateDBCatalog.log
7.3 执行脚本catalog.sql建立数据字典(必须)
@D:oracleora92rdbmsadmincatalog.sql;
7.4 执行脚本catexp7.sql,解决不同版本EXP问题(可选)
@D:oracleora92rdbmsadmincatexp7.sql;
7.5 执行脚本catblock.sql(可选)
@D:oracleora92rdbmsadmincatblock.sql;
7.6 执行脚本catproc.sql,建立PL/SQL功能的使用环境(必须)
@D:oracleora92rdbmsadmincatproc.sql;
7.7 执行脚本catblock.sql、owminst.plb(可选)
@D:oracleora92rdbmsadmincatoctk.sql;
@D:oracleora92rdbmsadminowminst.plb;
7.8 以SYSTEM用户登录系统
connect SYSTEM/manager
7.9 执行脚本pupbld.sql,创建 “产品用户配置文件” (Product User Profile) 表以及相关的过程(必须)
@D:oracleora92sqlplusadminpupbld.sql;
7.10 以SYSTEM用户登录系统
connect SYSTEM/manager
7.11 设置输出sqlPlusHelp.log
spool D:oracleora92assistantsdbcalogssqlPlusHelp.log
7.12 执行脚本hlpbld.sql、helpus.sql,建立SQL*Plus的帮助信息(可选)
@D:oracleora92sqlplusadminhelphlpbld.sql helpus.sql;
8 执行其他脚本安装一些附加的选项(可选)
D:oracleora92binsqlplus /nolog @D:oracleadminlectscriptsJServer.sql
D:oracleora92binsqlplus /nolog @D:oracleadminlectscriptsordinst.sql
D:oracleora92binsqlplus /nolog @D:oracleadminlectscriptsinterMedia.sql
D:oracleora92binsqlplus /nolog @D:oracleadminlectscriptscontext.sql
D:oracleora92binsqlplus /nolog @D:oracleadminlectscriptsxdb_protocol.sql
9 执行脚本postDBCreation.sql
9.1 以SYS用户登录
connect SYS/change_on_install as SYSDBA
9.2 设置输出postDBCreation.log
set echo on
spool D:oracleora92assistantsdbcalogspostDBCreation.log
9.3 执行脚本utlrp.sql,编译所有对象
@D:oracleora92rdbmsadminutlrp.sql;
9.4 关闭数据库
shutdown ;
9.5 以SYS用户登录
connect SYS/change_on_install as SYSDBA
9.6 设置输出postDBCreation.log
set echo on
spool D:oracleora92assistantsdbcalogspostDBCreation.log
9.7 根据PFILE建立SPFILE
create spfile='D:oracleora92databasespfilelect.ora' FROM pfile='D:oracleadminlectscriptsinit.ora';
9.8 启动数据库
startup ;
10 建库脚本
该贴被wei.yang编辑于2015-4-20 10:14:53