相关文章:Oracle 10G里手工建库的全过程
1、创建目录
mkdir d:oracleproduct10.1.0database
mkdir e:oracleadminOra10gbdump
mkdir e:oracleadminOra10gcdump
mkdir e:oracleadminOra10gcreate
mkdir e:oracleadminOra10gpfile
mkdir e:oracleadminOra10gudump
mkdir e:oracleflash_recovery_area
mkdir e:oracleoradata
mkdir e:oracleoradataOra10g
2、生成windows服务,创建密码文件,在cmd命令下运行
set ORACLE_SID=dbca –绿色部分设置oracle 实例名为 为ora10g
d:oracleproduct10.1.0DB_1binoradim.exe -new -sid ORA10G -startmode manual -spfile d:oracleproduct10.1.0DB_1binoradim.exe -edit -sid ORA10G -startmode a -spfile
–创建一个实例名为dbca 并且有手动启动方式改为自动启动
d:oracleproduct10.1.0DB_1binorapwd.exe file=d:oracleproduct10.1.0db_1PWDOra10g.ora password=sysPassword force=y
–用oracle自带的orapwd 为sys用户创建一个默认的密码为sysPassword
3、执行创建数据库脚本
D:oracleora92binsqlplus /nolog @D:oracleadmindbcascriptsCreateDB.sql
D:oracleora92binsqlplus /nolog @D:oracleadmindbcascriptsCreateDBFiles.sql
D:oracleora92binsqlplus /nolog @D:oracleadmindbcascriptsCreateDBCatalog.sql
D:oracleora92binsqlplus /nolog @D:oracleadmindbcascriptspostDBCreation.sql
–黑体部分就是创建数据库要调用的脚本
第一 CreateDB.sql
connect SYS/change_on_install as SYSDBA –这是刚刚我们设置的密码以sysdba身份连接到数据库
connect SYS/change_on_install as SYSDBA –这是刚刚我们设置的密码以sysdba身份连接到数据库
set echo on
spool D:oracleora92assistantsdbcalogsCreateDB.log 写日志
startup nomount pfile="D:oracleadmindbcascriptsinit.ora"; 调用参数文件 启动数据库到只装载实例阶段
CREATE DATABASE dbca
MAXINSTANCES 1
MAXLOGHISTORY 1
MAXLOGFILES 5
MAXLOGMEMBERS 3
MAXDATAFILES 100 –控制文件记录的相关最大日志数,日志组,最大数据文件数等限制
DATAFILE ‘D:oracleoradatadbcasystem01.dbf’ SIZE 250M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL
DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE ‘D:oracleoradatadbcatemp01.dbf’ SIZE 40M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
UNDO TABLESPACE "UNDOTBS1" DATAFILE ‘D:oracleoradatadbcaundotbs01.dbf’ SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED –创建系统,临时,回滚 表空间ITPUB个人空间!dJ5l {!i4W r f
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16 –字符集
LOGFILE GROUP 1 (‘D:oracleoradatadbcaredo01.log’) SIZE 102400K,
GROUP 2 (‘D:oracleoradatadbcaredo02.log’) SIZE 102400K,
GROUP 3 (‘D:oracleoradatadbcaredo03.log’) SIZE 102400K; –创建日志文件租和成员
spool off
exit;
第二.CreateDBFiles.sql
connect SYS/change_on_install as SYSDBA
set echo on
spool D:oracleora92assistantsdbcalogsCreateDBFiles.log
CREATE TABLESPACE "INDX" LOGGING DATAFILE ‘D:oracleoradatadbcaindx01.dbf’ SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;
CREATE TABLESPACE "TOOLS" LOGGING DATAFILE ‘D:oracleoradatadbcatools01.dbf’ SIZE 10M REUSE AUTOEXTEND ON NEXT 320K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;
CREATE TABLESPACE "USERS" LOGGING DATAFILE ‘D:oracleoradatadbcausers01.dbf’ SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ; –创建相关用户要用到的表空间
spool off
exit;
第三:CreateDBCatalog.sql
–创建system数据字典,存放到system表空间,相关表,视图等
connect SYS/change_on_install as SYSDBA
set echo on
spool D:oracleora92assistantsdbcalogsCreateDBCatalog.log
@D:oracleora92rdbmsadmincatalog.sql;
@D:oracleora92rdbmsadmincatexp7.sql;
@D:oracleora92rdbmsadmincatblock.sql;
@D:oracleora92rdbmsadmincatproc.sql;
@D:oracleora92rdbmsadmincatoctk.sql;
@D:oracleora92rdbmsadminowminst.plb;
connect SYSTEM/manager
@D:oracleora92sqlplusadminpupbld.sql;
connect SYSTEM/manager
set echo on
spool D:oracleora92assistantsdbcalogssqlPlusHelp.log
@D:oracleora92sqlplusadminhelphlpbld.sql helpus.sql;
spool off
spool off
exit;
第四: postDBCreation.sql
connect SYS/change_on_install as SYSDBA
set echo on
spool D:oracleora92assistantsdbcalogspostDBCreation.log
@D:oracleora92rdbmsadminutlrp.sql; –编译相关视图,包对象等
shutdown ; –关闭数据库
connect SYS/change_on_install as SYSDBA
set echo on
spool D:oracleora92assistantsdbcalogspostDBCreation.log
create spfile=’D:oracleora92databasespfiledbca.ora’ FROM pfile=’D:oracleadmindbcascriptsinit.ora’;
–创建服务器参数文件代替文件初始化参数文件,方便有时在不重启数据库的情况下可以使参数生效
从上面可以看到spfile文件的存放位置
startup ; –启动数据库 ,创建数据库完成
exit;
从上面可以看出,创建数据库有以下10个步骤
Step 1: 创建相关trace目录文件夹
Step 2:创建实例,密码 启动方式
Step 3:创建初始化参数文件 init.ora
Step 4: 连接到实例
Step 5: 启动实例到nomount状态
Step 6:创建数据库
Step 7:创建表空间
Step 8: 运行脚本创建数据字典
Step 9: 创建服务器参数文件(这步不是必须的,但oracle建议做这步) 好处会在以后的总结中列出
下面也贴出linux下脚本,和windows下几乎差不多
#!/bin/sh
mkdir /oradata/ora9i
mkdir /oradata/ora9i/controlfile
mkdir /oradata/ora9i/redofile
mkdir /orasys/oracle/admin
mkdir /orasys/oracle/admin/ora9i
mkdir /orasys/oracle/admin/ora9i/bdump
mkdir /orasys/oracle/admin/ora9i/cdump
mkdir /orasys/oracle/admin/ora9i/create
mkdir /orasys/oracle/admin/ora9i/udump
mkdir /orasys/oracle/admin/ora9i/pfile
cp init.ora /orasys/oracle/product/9.2.0/dbs/.
export ORACLE_BASE=/orasys/oracle
export ORACLE_HOME=$ORACLE_BASE/product/9.2.0
export ORACLE_SID=ora9i
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH
export PATH=$PATH:$ORACLE_HOME/bin
echo Add this entry in the oratab: ora9i:/orasys/oracle/product/9.2.0:Y
/orasys/oracle/product/9.2.0/bin/orapwd file=/orasys/oracle/product/9.2.0/dbs/orapwora9i password=change_on_install
/orasys/oracle/product/9.2.0/bin/sqlplus /nolog @/home/oracle/create_script/CreateDB.sql
/orasys/oracle/product/9.2.0/bin/sqlplus /nolog @/home/oracle/create_script/CreateDBFiles.sql
/orasys/oracle/product/9.2.0/bin/sqlplus /nolog @/home/oracle/create_script/CreateDBCatalog.sql
/orasys/oracle/product/9.2.0/bin/sqlplus /nolog @/home/oracle/create_script/postDBCreation.sql
—-想了解更多的数据库相关异常处理怎么解决关注<计算机技术网(www.ctvol.com)!!>
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/dtteaching/81656.html