您所在的位置: 首页>>读书频道>>数据库>>Oracle>>

1.2.9 sql.bsq文件与数据库创建

http://book.51cto.com  2007-09-04 13:29  盖国强  人民邮电出版社  我要评论(0)

1.2.9 sql.bsq文件与数据库创建
在CREATE DATABASE的过程中,Oracle会调用$ORACLE_HOME/rdbms/admin/sql.bsq脚本,用于创建数据字典,这是非常重要的一个脚本,其中存储了数据字典的创建语句及注释说明,当我们对某些数据字典存在兴趣时,可以通过检查这个文件得到更为详细的信息,例如对于控制数据库启动的bootstrap$表,其创建语句就可以从这个文件中找到:

create table bootstrap$
( line#         number not null,                       /* statement order id */
obj#          number not null,                            /* object number */
sql_text      varchar2("M_VCSZ") not null)                    /* statement */
storage (initial 50K)            /* to avoid space management during IOR I */
//                                            /* "//" required for bootstrap */

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.
<...ignore SGA info here...>

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

此时警告日志(alert_<oracle_sid>.log)中会记录如下信息:
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文件的位置(但是通常这些是不建议变更的)。

【责任编辑:雪花 TEL:(010)68476606-8007】

回书目   上一节   下一节
Sun以10亿美元并购开源数据库厂商MySQL
甲骨文Oracle 11g正式发布
Oracle数据库开发之PL/SQL基础应用
Oracle较真SAP-商业管理软件之战一触即发
Oracle数据库开发基础教程
 
 验证码: (点击刷新验证码)   匿名发表
  • Visual C++ 完全自学宝典

  • 作者:强锋科技,朱洪波
  • Visual C++ 6.0是微软公司为程序人员提供的Visual Studio 6.0工具套件中的重要组成部分。本书由浅入深地介绍使用Visual C++ 6.0..
Copyright©2005-2008 51CTO.COM 版权所有