完整的手工建立ORACLE数据库步骤
作者:Winder(杭州)
E_MAIL: lswandlm@163.net
URL: http://www.qyhhschool.com
关键词:经过排错的 经过调试的 完整的 整理他人的 手工建库 ORACLE
数据库: Oracle 8i R2 (8.1.6)
安装路径:/data/ora816
数据库实例:web
数据库全局名称:web.edi.com
1、手工创建相关目录
/data/ora816/admin/web
/data/ora816/admin/web/adhoc
/data/ora816/admin/web/bdump
/data/ora816/admin/web/cdump
/data/ora816/admin/web/create
/data/ora816/admin/web/exp
/data/ora816/admin/web/pfile
/data/ora816/admin/web/udump
/data/ora816/oradata/web
/data/ora816/oradata/web/archive
2、手工创建初始化启动参数文件:/data/ora816/admin/web/pfile/initweb.ora
检查$ORACLE_HOME/dbs目录下是否有初始化文件,比如如果您的sid是web,则在此目录下应该有一个initweb.ora的文件,如果没有,您可以将init.ora文件复制成initweb.ora文件:cp init.ora initweb.ora.如果您的sid是web,则在此目录下应该有一个initweb.ora的文件,如果没有,您可以将init.ora文件复制成initweb.ora文件:cp init.ora initweb.ora.
ln -s /data/ora816/admin/web/initweb.ora /data/ora816/dbs/initweb.ora
附:initweb.ora内容(见后)
3、使用orapwde命令,创建/data/ora816/dbs/orapwweb
命令:orapwd file=/data/ora816/dbs/orapwweb password=ORACLE entries=5
4、检查环境变量是否设置:ORACLE_HOME,ORACLE_SID,检查方法:输入命令echo $ORACLE_HOME,或者echo $ORACLE_SID,如果这两个环境变量没有设置,您将会发现输出一个空行,这时您可以通过以root权限登录,修改/etc/profile文件,在末尾填上:ORACLE_HOME=您安装ORACLE时的主路径,如/data/ora816 ORACLE_SID=您安装时所定的sid,如orcl,我在上面的文件中是web
export ORACLE_HOME ORACLE_SID
同时您还应该修改PATH环境变量,以便于使用工具svrmgrl,sqlplus等。将bin目录加入到PATH中。
5、分别检查是否存在下列文件$ORACLE_HOME/rdbms/admin/catdbsyn.sql,$ORACLE_HOME/rdbms/admin/catproc.sql,$ORACLE_HOME/sqlplus/admin/pupbld.sql,如果不存在,请重新安装您的oracle系统。
6、准备创建脚本:create_db.sql
rem 脚本开始
connect internal
startup nomount pfile="$ORACLE_HOME/admin/web/pfile/initweb.ora"
set echo on
spool makedb.log
create database web
datafile '$ORACLE_HOME/oradata/web/web_syst_01.dbf' size 500M reuse
logfile
'$ORACLE_HOME/oradata/web/web_redo_01.dbf' size 10M reuse,
'$ORACLE_HOME/oradata/web/web_redo_02.dbf' size 10M reuse,
'$ORACLE_HOME/oradata/web/web_redo_03.dbf' size 10M reuse
MAXLOGFILES 32
MAXLOGMEMBERS 2
MAXLOGHISTORY 1
MAXDATAFILES 254
MAXINSTANCES 1
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET ZHS16GBK;
connect INTERNAL/oracle
rem --修改系统表空间
ALTER TABLESPACE SYSTEM DEFAULT STORAGE ( INITIAL 64K NEXT 64K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 50);
ALTER TABLESPACE SYSTEM MINIMUM EXTENT 64K;
connect INTERNAL/oracle
rem --修改系统表空间
ALTER TABLESPACE SYSTEM DEFAULT STORAGE ( INITIAL 64K NEXT 64K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 50);
ALTER TABLESPACE SYSTEM MINIMUM EXTENT 64K;
rem --创建回滚表空间
CREATE TABLESPACE RBS DATAFILE '/data/ora816/oradata/web/rbs01.dbf' SIZE 256M REUSE
AUTOEXTEND ON NEXT 5120K
MINIMUM EXTENT 512K
DEFAULT STORAGE ( INITIAL 512K NEXT 512K MINEXTENTS 8 MAXEXTENTS 4096);
rem --创建用户表空间
CREATE TABLESPACE USERS DATAFILE '/data/ora816/oradata/web/users01.dbf' SIZE 128M REUSE
AUTOEXTEND ON NEXT 1280K
MINIMUM EXTENT 128K
DEFAULT STORAGE ( INITIAL 128K NEXT 128K MINEXTENTS 1 MAXEXTENTS 4096 PCTINCREASE 0);
rem --创建临时表空间
CREATE TABLESPACE TEMP DATAFILE '/data/ora816/oradata/web/temp01.dbf' SIZE 32M REUSE
AUTOEXTEND ON NEXT 640K
MINIMUM EXTENT 64K
DEFAULT STORAGE ( INITIAL 64K NEXT 64K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0) TEMPORARY;
rem --创建工具表空间
CREATE TABLESPACE TOOLS DATAFILE '/data/ora816/oradata/web/tools01.dbf' SIZE 64M REUSE
AUTOEXTEND ON NEXT 320K
MINIMUM EXTENT 32K
DEFAULT STORAGE ( INITIAL 32K NEXT 32K MINEXTENTS 1 MAXEXTENTS 4096 PCTINCREASE 0);
rem --创建索引表空间
CREATE TABLESPACE INDX DATAFILE '/data/ora816/oradata/web/indx01.dbf' SIZE 32M REUSE
AUTOEXTEND ON NEXT 1280K
MINIMUM EXTENT 128K
DEFAULT STORAGE ( INITIAL 128K NEXT 128K MINEXTENTS 1 MAXEXTENTS 4096 PCTINCREASE 0);
rem --创建回滚段
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 );
rem --使回滚段在线
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;
rem --修改sys用户的临时表空间为TEMP
alter user sys temporary tablespace TEMP;
rem --创建数据字典表
connect system/manager
@$ORACLE_HOME/rdbms/admin/catdbsyn.sql
connect internal
@/data/ora816/rdbms/admin/catalog.sql;
@/data/ora816/rdbms/admin/catexp7.sql
@/data/ora816/rdbms/admin/catproc.sql
@/data/ora816/rdbms/admin/caths.sql
connect system/manager
@/data/ora816/sqlplus/admin/pupbld.sql
connect internal/oracle
@/data/ora816/rdbms/admin/catrep.sql
rem --修改system用户默认表空间和临时表空间
alter user system default tablespace SYSTEM;
alter user system temporary tablespace TEMP;
spool off
rem 脚本结束
7、执行脚本
您可以进行执行脚本了,转到目录:$ORACLE_HOME/dbs中去,并且将上面的create_db.sql也放到此目录中,下面开始了:
键入命令:svrmgrl回车
SVRMGR>connect internal
connected.
SVRMGR>startup回车
SVRMGR>@create_db.sql回车(ok,下面您就可以看到屏幕在不断的显时操作过程,大概需要半个多小时的时间或许还要长一点点)。
执行完毕之后您可能需要退出去
SVRMGR>exit
没有错误的话,现在您的数据库已经生成了。
8、生成SQL*Plus帮助系统
sqlplus SYSTEM/manager
@/data/ora816/sqlplus/admin/help/helpbld.sql helpus.sql