eygle.com   eygle.com
eygle.com eygle
eygle.com  
 

« 警惕骗子-以同学名义行骗 | Blog首页 | 中国首届杰出数据库工程师评选前10名单 »

sql.bsq与数据库的创建

如果我们使用脚本创建数据库,那么最先运行的是一个叫做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文件的位置。

ixora网站上有一篇文章可以参考:
http://www.ixora.com.au/tips/creation/bsq.htm
Itpub上的相关文章:
http://www.itpub.net/199099.html

-The End-

 


历史上的今天...
    >> 2010-08-23文章:
    >> 2009-08-23文章:

无觅

By eygle on 2006-08-23 16:55 | Comments (2) | Internal | 882 |

2 Comments

这个还是少改为好, 哈哈

谢谢你,我不知道该如何称呼你。不过我是很感谢你,这个问题困扰了我很长时间,也许你的回答能帮我你个大忙。感谢你的相告,你辛苦了。


CopyRight © 2004~2020 云和恩墨,成就未来!, All rights reserved.
数据恢复·紧急救援·性能优化 云和恩墨 24x7 热线电话:400-600-8755 业务咨询:010-59007017-7040 or 7037 业务合作: marketing@enmotech.com