sql.bsq与数据库的创建
文章作者 100test 发表时间 2007:03:14 13:43:51
来源 100Test.Com百考试题网
如果我们使用脚本创建数据库,那么最先运行的是一个叫做CreateDB.sql的脚本。
这个脚本发出CREATE DATABASE的命令,具体类似如下的例子:
CREATE DATABASE eygle
MAXINSTANCES 1
MAXLOGHISTORY 1
MAXLOGFILES 5
MAXLOGMEMBERS 3
MAXDATAFILES 100
DATAFILE /opt/oracle/oradata/eygle/system01.dbf
SIZE 250M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL
DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE /opt/oracle/oradata/eygle/temp01.dbf
SIZE 40M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
UNDO TABLESPACE "UNDOTBS1" DATAFILE /opt/oracle/oradata/eygle/undotbs01.dbf
SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
LOGFILE GROUP 1 ( /opt/oracle/oradata/eygle/redo01.log ) SIZE 10240K,
GROUP 2 ( /opt/oracle/oradata/eygle/redo02.log ) SIZE 10240K,
GROUP 3 ( /opt/oracle/oradata/eygle/redo03.log ) SIZE 10240K.
exit.
在这个过程中,Oracle会调用$ORACLE_HOME/rdbms/admin/sql.bsq脚本,用于创建数据字典。
这个文件的位置受到一个隐含的初始化参数 (_init_sql_file )的控制:
SQL> @GetParDescrb.sql
Enter value for par: init_sql
old 6: AND x.ksppinm LIKE %&.par%
new 6: AND x.ksppinm LIKE %init_sql%
NAME VALUE DESCRIB
--------------- --------------------- ------------------------------------------------------------
_init_sql_file ?/rdbms/admin/sql.bsq File containing SQL statements to execute upon database creation
如果在创建过程中,Oracle无法找到sql.bsq文件,则数据库创建将会出错.
如果我们移除sql.bsq文件,再看这样一个数据库创建过程:
[oracle@jumper scripts]$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.4.0 - Production on Fri Aug 18 15:45:26 2006
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to an idle instance.
SQL> startup nomount.
ORACLE instance started.
Total System Global Area 252777592 bytes
Fixed Size 451704 bytes
Variable Size 134217728 bytes
Database Buffers 117440512 bytes
Redo Buffers 667648 bytes
SQL> @CreateDB.sql
CREATE DATABASE eygle
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
此时日志中会记录:
Fri Aug 18 15:45:49 2006
Errors in file /opt/oracle/admin/eygle/udump/eygle_ora_3632.trc:
ORA-01501: CREATE DATABASE failed
ORA-01526: error in opening file ?/rdbms/admin/sql.bsq
ORA-07391: sftopn: fopen error, unable to open text file.
Error 1526 happened during db open, shutting down database
USER: terminating instance due to error 1526
Fri Aug 18 15:45:49 2006
Errors in file /opt/oracle/admin/eygle/bdump/eygle_ckpt_3623.trc:
ORA-01526: error in opening file
Instance terminated by USER, pid = 3632
ORA-1092 signalled during: CREATE DATABASE eygle
MAXINSTANCES 1
MAXLOGHISTORY...
这就是sql.bsq文件在数据库创建过程中的作用。知道了这个内容之后,我们可以通过手工修改sql.bsq文件来更改数据库字典对象参数,从而实现特殊要求数据库的创建或测试自定义库。我们也可以通过修改_init_sql_file参数来重定位sql.bsq文件的位置。