创建Oracle数据库
数据库名:mydb
1:复制一个已经存在的数据库目录D:Oracleproduct10.1.0Db_1adminsample
到D:Oracleproduct10.1.0admin目录下,改名为mydb,
将mydbpfileinitsmpl.ora删除,因为这个参数文件比较旧,从下面目录中复制
一个参数文件D:Oracleproduct10.1.0adminorclpfileinit.ora
将改文件放到mydbpfile下,改名为initmydb.ora,并设置以下参数:
db_domain=zhiqiao.com.cn
db_name=mydb
instance_name=mydb
control_files=( "D:Oracleproduct10.1.0oradatamydbcontrol01.ctl", "D:Oracleproduct10.1.0oradatamydbcontrol02.ctl", "D:Oracleproduct10.1.0oradataorclcontrol03.ctl")
background_dump_dest=D:Oracleproduct10.1.0adminmydbbdump
core_dump_dest=D:Oracleproduct10.1.0adminmydbcdump
user_dump_dest=D:Oracleproduct10.1.0adminmydbudump
2:在D:Oracleproduct10.1.0Db_1database中创建数据库启动时直接读取的参数文件
initmydb.ora内容为IFILE='D:Oracleproduct10.1.0adminmydbpfile'
3:使用orapwd命令创建数据库具有SYSDBA权限用户的口令字文件PWDmydb.ora,
该用户可以管理数据库的启动与关闭,其存储目录为:
D:Oracleproduct10.1.0Db_1database
在系统命令行输入如下命令创建口令文件
C:>orapwd file=D:Oracleproduct10.1.0db_1databasePWDmydb.ora
password=mydb entries=2
4:通过实例管理命令在服务表里创建一个实例管理服务,设置启动方式为手动
C:>oradim -NEW -SID mydb -STARTMODE manual
-pfile "d:Oracleproduct10.1.0adminprodpfileinitmydb.ora"
----》奇怪的是服务管理窗口中显示为启动,但关闭出错?
C:>oradim -SHUTDOWN -SID mydb -USRPWD mydb
ORA-01012: not logged on
----》启动出错
C:>oradim -STARTUP -SID mydb -USRPWD mydb
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file
'D:Oracleproduct10.1.0adminmydbpfile'
-----》因为没创建spfile因此在此指定
C:>oradim -STARTUP -SID mydb -USRPWD mydb
-PFILE "d:Oracleproduct10.1.0adminmydbpfileinitmydb.ora"
ORA-00205: error in identifying controlfile, check alert log for more info
D:Oracleproduct10.1.0adminmydbbdumpalert_mydb.log中显示错误原因
大致意思是找不到控制文件,我想可能应该以nomount方式打开,但oradim没提供这个
选项,于是启动sqlplus。
C:>sqlplus /nolog
SQL*Plus: Release 10.1.0.2.0 - Production on 星期三 4月 11 10:49:13 2007
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> connect /as sysdba
ERROR:
ORA-12560: TNS:protocol adapter error
SQL> connect sys/mydb as sysdba
ERROR:
ORA-12560: TNS:protocol adapter error
SQL> exit
C:>set Oracle_sid=mydb
C:>sqlplus /nolog
SQL*Plus: Release 10.1.0.2.0 - Production on 星期三 4月 11 10:50:21 2007
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> conn sys/mydb as sysdba
Connected.
SQL> startup nomount
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file 'D:Oracleproduct10.1.0adminmydbpfile'
SQL> startup nomount pfile="d:Oracleproduct10.1.0adminmydbpfileinitmydb.ora"
ORA-01081: cannot start already-running Oracle - shut it down first
SQL> shutdown
ORA-01507: database not mounted
Oracle instance shut down.
SQL> startup nomount pfile="d:Oracleproduct10.1.0adminmydbpfileinitmydb.ora"
Oracle instance started.
Total System Global Area 171966464 bytes
Fixed Size 787988 bytes
Variable Size 145750508 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
----》因为每次都要指定pfile不方便,可以创建一个
C:>sqlplus /nolog
SQL*Plus: Release 10.1.0.2.0 - Production on 星期三 4月 11 11:02:57 2007
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> conn sys/mydb as sysdba
Connected to an idle instance.
SQL> create spfile from pfile;
create spfile from pfile
*
ERROR at line 1:
ORA-01078: failure in processing system parameters
LRM-00113: error when processing file
'D:Oracleproduct10.1.0adminmydbpfile'
LRM-00109: could not open parameter file
'D:Oracleproduct10.1.0adminmydbpfile'
----》上面的错误原因是第二步造成的,其中IFILE="....initmydb.ora"才行。
SQL> create spfile from pfile;
File created.