上一篇 / 下一篇 2011-03-25 00:56:30 / 个人分类:Oracle database 笔记 心得
windows XP下,使用OMF方式手工创建数据库
1.创建数据库实例,实例名为ora10g(只是Windows平台需要,Unix平台不需要)
D:\oraclexe\app\oracle\product\10.2.0\server\BIN>oradim -new -sid ora10g
实例已创建。
2.为了sys用户可以连入数据库执行操作,先创建数据库的密码文件,密码文件的名称必须为PWDsid.ora
D:\oraclexe\app\oracle\product\10.2.0\server\BIN>orapwd password=oracle file=D:\ORACLEXE\APP\ORACLE\PRODUCT\10.2.0\SERVER\DATABASE\PWDora10g.ora
OPW-00001:无法打开口令文件
**建立相关目录**
D:\oraclexe\app\oracle\product\10.2.0\server\BIN>orapwd password=oracle file=D:\ORACLEXE\APP\ORACLE\PRODUCT\10.2.0\SERVER\DATABASE\PWDora10g.ora
3.创建下列目录,以存放数据文件和dump信息
#数据文件目录
D:\oraclexe\oradata\ora10g
#background dump目录
D:\oraclexe\app\oracle\admin\ora10g\bdump
#core dump目录
D:\oraclexe\app\oracle\admin\ora10g\cdump
#user dump目录
D:\oraclexe\app\oracle\admin\ora10g\udump
4.修改listener.ora为下列信息,把此数据库注册在监听器中(可选)在D:\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN下
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = D:\oracle\app\oracle\product\10.2.0\server)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:\oracle\app\oracle\product\10.2.0\server)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_ora10g))
(ADDRESS = (PROTOCOL = TCP)(HOST = ssjwork)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (ora10g)
根据文件添加
5.为了可以访问数据库,修改tnsnames.ora为下列信息
在D:\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN下
ORA10G =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ssjwork)(PORT = 1521))
(CONNECT_DATA =
(SERVER = dedicated)
(SERVICE_NAME = ora10g)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_ora10g))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_ora10g))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
6.建立pfile文件D:\ORACLEXE\APP\ORACLE\PRODUCT\10.2.0\SERVER\DATABASE\initora10g.ora,文件的内容如下:(注意文件名)
background_dump_dest='D:\oraclexe\app\oracle/admin/ora10g/bdump'
compatible='10.2.0.1.0'
control_files='D:\oraclexe\oradata\ORA10G\control01.ctl','D:\oraclexe\oradata\ORA10G\control02.ctl'
core_dump_dest='D:\oraclexe\app\oracle/admin/ora10g/cdump'
db_block_size=8192
db_name='ora10g'
db_recovery_file_dest='D:\oraclexe\app\oracle/flash_recovery_area'
db_recovery_file_dest_size=2147483648
pga_aggregate_target=41943040
processes=150
remote_login_passwordfile='EXCLUSIVE'
sga_max_size=167772160
sga_target=125829120
undo_management='AUTO'
undo_tablespace='undotbs1'
user_dump_dest='D:\oraclexe\app\oracle/admin/ora10g/udump'
db_create_file_dest='D:\oraclexe\oradata\'
db_create_online_log_dest_1='D:\oraclexe\oradata\'
7.连入数据库,并创建spfile文件
D:\oraclexe\app\oracle\product\10.2.0\server\BIN>set ORACLE_SID=ora10g
D:\oraclexe\app\oracle\product\10.2.0\server\BIN>sqlplus.exe / as sysdba
SQL*Plus: Release10.2.0.1.0 - Production on星期四3月24 13:59:53 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
已连接到空闲例程。
SQL>create spfile from pfile;
文件已创建。
8.启动数据库到nomount
SQL>startup nomount
ORACLE例程已经启动。
Total System Global Area 167772160 bytes
Fixed Size 1286364 bytes
Variable Size 104861476 bytes
Database Buffers 58720256 bytes
Redo Buffers 2904064 bytes
SQL>
9.执行creata database脚本
#createdb.sql脚本的具体内容如下:
create database ora10g
user sys identified by oracle
user system identified by oracle
default temporary tablespace temp
undo tablespace undotbs1
character set utf8
national character set al16utf16;
SQL>@D:\oraclexe\app\oracle\admin\ora10g\create\createdb.sql
10.执行catalog.sql,创建数据库的数据字典视图
SQL>spool D:\oraclexe\catalog.log
SQL>@D:\oraclexe\app\oracle\product\10.2.0\server\RDBMS\ADMIN\catalog.sql
SQL>spool off
11.执行catproc.sql,创建执行PL/SQL程序所需的所有包
SQL>spool D:\oraclexe\catproc.log
SQL>@D:\oraclexe\app\oracle\product\10.2.0\server\RDBMS\ADMIN\catproc.sql
SQL>spool off
到此数据库ora10g创建完毕,可以正常使用了。
需要注意的地方:
(1)在10g中,如果system01.dbf这个文件用extent management local的话,必须创建一个temporary表空间。
(2)10g必须创建sysaux01.dbf这个文件
(3)如果以上步骤出现错误,而错误提示为乱码的话,可以退出SQLPLUS,然后设置环境变量set nls_lang=american_america.zhs16gbk(windows),然后再登录数据库。
总结:创建过程中出现了很多的问题和报错,出现报错后查看告警日志alert_ora10g,本例中路径是D:\oraclexe\app\oracle\admin\ora10g\bdump,根据错误号可以google一下,能解决很多问题,具体出现的一些问题我会在日志中记录下来。