Oracle数据库主要有Instance和Database组成。只要把spfile创建好,Instance基本就可以启动了,剩下就把database的三大文件(控制文件、数据文件、日志文件)创建好,最后进行一些善后处理,基本就完成了创建工作。
所以我把创建数据库总结为一个变量、两个文件,三条语句,外加两个脚本。
一个变量就是Oracle_SID环境变量,两个文件是spfile和password file。有了这三个东西,就能完成Instance的创建。
三条语句,即create databse和两条表空间创建语句。有了这三个就能创建出database的三大文件。
两个脚本,即CATALOG.SQL 用来创建数据字典表和动态性能视图,CATPROC.SQL 用来创建PL/SQL所需物件。
主要步骤如下:
Step 1: Decide on Your Instance Identifier (SID)
Step 2: Establish the Database Administrator Authentication Method
Step 3: Create the Initialization Parameter File
Step 4: Connect to the Instance
Step 5: Create a Server Parameter File (Recommended)
Step 6: Start the Instance
Step 7: Issue the CREATE DATABASE Statement
Step 8: Create Additional Tablespaces
Step 9: Run Scripts to Build Data Dictionary Views
Step 10: Run Scripts to Install Additional Options (Optional)
Step 11: Back Up the Database.
具体步骤见Oracle 10g的官方文档Administrator's Guide。但是文档的create database语句有点问题,调整后的语句如下:
CREATE DATABASE mynewdb
USER SYS IDENTIFIED BY password
USER SYSTEM IDENTIFIED BY password
LOGFILE GROUP 1 ('/u01/oracle/oradata/mynewdb/redo01.log') SIZE 100M,
GROUP 2 ('/u01/oracle/oradata/mynewdb/redo02.log') SIZE 100M,
GROUP 3 ('/u01/oracle/oradata/mynewdb/redo03.log') SIZE 100M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
DATAFILE '/u01/oracle/oradata/mynewdb/system01.dbf' SIZE 325M REUSE
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/u01/oracle/oradata/mynewdb/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE tbs_1
DATAFILE '/u01/oracle/oradata/mynewdb/tbs01.dbf' SIZE 200M REUSE
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/oracle/oradata/mynewdb/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs1
DATAFILE '/u01/oracle/oradata/mynewdb/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;