简单的按照文档(B19306_01/b14231)说明创建数据库。
遇到一点小问题如下述;
平台:
# cat /etc/release
Solaris 10 1/06 s10x_u1wos_19a X86
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
Use is subject to license terms.
Assembled 07 December 2005
数据库版本:
SQL> select * from v$version where rownum<2;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Prod
步骤:
1.设置数据库SID
nice@nice:~% export ORACLE_SID=test
检查设置的情况:
nice@nice:~% env | grep ORA
ORACLE_SID=test
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
2.建立数据库管理员权限
因使用的用户nice为安装数据库的用户,权限为:
# id -a nice
uid=100(nice) gid=100(oinstall) groups=101(dba),102(oper)
所以省略此步骤
3.创建初始化参数
将$ORACLE_HOME/dbs下的init.ora复制inittest.ora,然后编辑相应的项。
nice@nice:~%cat /u01/app/oracle/product/10.2.0/db_1/dbs/inittest.ora
db_name=test
db_files = 180
db_file_multiblock_read_count = 16
shared_pool_size = 117440512
processes = 100
log_buffer = 2867200
control_files = '/u01/app/oracle/oradata/test/control01.ctl', '/u03/app/oracle/test/control02.ctl'
4.连接到实例
sqlplus / as sysdba
5.创建spfile(可选),并使用创建的spfile启动数据库
SQL> create spfile='/u01/app/oracle/product/10.2.0/db_1/dbs/spfiletest.ora' from pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/inittest.ora'
SQL> shutdown
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 197132288 bytes
Fixed Size 1279288 bytes
Variable Size 142609096 bytes
Database Buffers 50331648 bytes
Redo Buffers 2912256 bytes
6.使用create database语句创建数据库
CREATE DATABASE test
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/test/redo01a.log','/u03/app/oracle/test/redo01b.log') SIZE 10M,
GROUP 2 ('/u01/app/oracle/oradata/test/redo02a.log','/u03/app/oracle/test/redo02b.log') SIZE 10M,
GROUP 3 ('/u01/app/oracle/oradata/test/redo03a.log','/u03/app/oracle/test/redo03b.log') SIZE 10M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
DATAFILE '/u01/app/oracle/oradata/test/system01.dbf' SIZE 325M REUSE
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/u01/app/oracle/oradata/test/sysaux01.dbf' SIZE 280M REUSE
DEFAULT TABLESPACE users LOGGING
DATAFILE '/u01/app/oracle/oradata/test/user01.dbf'
SIZE 150M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/test/temp01.dbf'
SIZE 20M REUSE EXTENT MANAGEMENT LOCAL
UNDO TABLESPACE undotbs
DATAFILE '/u01/app/oracle/oradata/test/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
执行语句后报错:
CREATE DATABASE test
*
ERROR at line 1:
ORA-30014: operation only supported in Automatic Undo Management mode
修正方法:
关闭数据库:
SQL>shutdown immediate;
编辑文件initest.ora,添加undo_management='AUTO'
重新启动数据库
SQL>startup nomount pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/inittest.ora'
再执行上述create database语句后成功创建数据库;
7.创建其他表空间
因在创建数据库已经创建了USERS表空间,并设置成默认的表空间了,所以只创建一个用于索引的表空间:
SQL>CREATE TABLESPACE indx LOGGING
DATAFILE '/u01/app/oracle/oradata/test/indx01.dbf'
SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL;
8.创建数据字典和视图
SQL>@?/rdbms/admin/catalog.sql
SQL> @?/rdbms/admin/catproc.sql
9.备份数据库
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /u01/app/oracle/product/10.2.0/db_1/dbs/arch
Oldest online log sequence 38
Current log sequence 40
将数据库冷备份