六步 : 和实例进行连接
[ora10@localhost dbs]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jul 18 00:12:23 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> connect /as sysdba
Connected to an idle instance.
如果前面环境变量设置有问题的话, 这里一定会出错。我这里就卡了。又回去把环境变量认真检查了一下。
第七步:,创建一个服务器参数文件
这一步也很简单,紧跟上一步,在进入
数据库的状态,输入以下命令创建spfile
SQL> create spfile from pfile;
File created.
SQL> ! //退出sql
[ora10@localhost dbs]$ ll
总计 60
-rwxr--r-- 1 ora10 dba 88 07-18 00:11 chongshi.env
-rw-rw---- 1 ora10 dba 1544 07-17 21:27 hc_ora10.dat
-rw-r--r-- 1 ora10 dba 19 07-17 23:33 initchongshi.ora
-rw-r----- 1 ora10 dba 12920 2001-05-03 initdw.ora
-rw-r----- 1 ora10 dba 8385 1998-09-11 init.ora
-rw-rw---- 1 ora10 dba 24 06-18 23:29 lkORA10
-rw-r----- 1 ora10 dba 1536 06-18 23:32 orapwora10
-rw-r----- 1 ora10 dba 2560 07-16 21:02 orapwtest
-rw-r----- 1 ora10 dba 1536 07-18 21:10 spfilechongshi.ora
-rw-r----- 1 ora10 dba 3584 07-17 22:00 spfileora10.ora
通过pfile(initchongshi.ora)文件生成spfile(spfilechongshi.ora)文件!
其实,这一步和第四步类似,都是创建启动文件。可以缺省。对后续无影响。但是,oracle推荐你创建,如果你这里创建的话,新生成的数据库使用spfile,不创建使用pfile。Spfile和pfile有什么区别。新旧区别,新的但然比旧的好。
www.2cto.com
第八步: 启动实例
[ora10@localhost dbs]$ exit
exit
SQL> startup nomount 启动数据库
ORACLE instance started.
Total System Global Area 113246208 bytes
Fixed Size 1218004 bytes
Variable Size 58722860 bytes
Database Buffers 50331648 bytes
Redo Buffers 2973696 bytes
SQL>
这个时候,我们后台数据库并没有启动。那我打入startup nomount 命令其实读取的是spfilechongshi.ora 文件的内容,由此看出。上一步必不可少。呵呵!
第九步:发出创建数据库语句
这一步创建数据库,还是一句命令搞定。需要注意的,这里创建的数据库名字与第四步创建的参数文件里设置的名字一致。
[ora10@localhost dbs]$ cat initchongshi.ora
db_name='chongshi'
[ora10@localhost dbs]$ exit
exit
SQL> create database chongshi;
创建文件比较大,会有点慢,请耐心等一下!
[ora10@localhost dbs]$ ll
总计 188628
-rwxr--r-- 1 ora10 dba 88 07-18 00:11 chongshi.env
-rw-r----- 1 ora10 dba 6078464 07-18 21:39 cntrlchongshi.dbf
-rw-r----- 1 ora10 dba 81928192 07-18 21:39 dbs1chongshi.dbf
-rw-rw---- 1 ora10 dba 1544 07-18 22:03 hc_chongshi.dat
-rw-rw---- 1 ora10 dba 1544 07-17 21:27 hc_ora10.dat
-rw-r--r-- 1 ora10 dba 19 07-17 23:33 initchongshi.ora
-rw-r----- 1 ora10 dba 12920 2001-05-03 initdw.ora
-rw-r----- 1 ora10 dba 8385 1998-09-11 init.ora
-rw-rw---- 1 ora10 dba 24 07-18 21:39 lkCHONGSHI
-rw-rw---- 1 ora10 dba 24 06-18 23:29 lkORA10
-rw-r----- 1 ora10 dba 52429312 07-18 21:39 log1chongshi.dbf
-rw-r----- 1 ora10 dba 52429312 07-18 21:39 log2chongshi.dbf
-rw-r----- 1 ora10 dba 1536 06-18 23:32 orapwora10
-rw-r----- 1 ora10 dba 2560 07-16 21:02 orapwtest
-rw-r----- 1 ora10 dba 1536 07-18 21:10 spfilechongshi.ora
-rw-r----- 1 ora10 dba 3584 07-17 22:00 spfileora10.ora
上面列表中标红的就是我们创建的数据库
============================================小隔开一下===========================
OK!通过上面简单的几步,我们已经完整的创建了一个数据库,由于我们设置的太简单了。这个数据库基本是不能用的。麻雀虽然小,步骤很全。
手工创建数据库的难点就是第四步与第九步。
第四步,因为我上面的pfile文件设置太过简单。第九步,创建一下比较实用的数据库也不是那么简单一下命令就稿定的。 www.2cto.com
所以把我们创建的几个文件干掉,重新再来。哈哈!你怒了?
cntrlchongshi.dbf
dbs1chongshi.dbf
log1chongshi.dbf
log2chongshi.dbf
initchongshi.ora
spfilechongshi.or