手工建庫步驟
Step 1: Specify an Instance Identifier (SID)(指定一個例項的識別符號SID)
Step 2: Ensure That the Required Environment Variables Are Set(確認環境變數的設定)
Step 3: Choose a Database Administrator Authentication Method(決定資料庫管理員的認證方法)
Step 4: Create the Initialization Parameter File(建立初始化的引數檔案資訊)
Step 5: (Windows Only) Create an Instance
Step 6: Connect to the Instance(連線例項)
Step 7: Create a Server Parameter File(建立spfile)
Step 8: Start the Instance(啟動例項)
Step 9: Issue the CREATE DATABASE Statement(建立DATABASE的語句)
Step 10: Create Additional Tablespaces(建立額外的表空間)
Step 11: Run Scripts to Build Data Dictionary Views(執行指令碼建立資料庫字典檢視)
Step 12: (Optional) Run Scripts to Install Additional Options
Step 13: Back Up the Database.
Step 14: (Optional) Enable Automatic Instance Startup
Step 1: Specify an Instance Identifier (SID)(指定一個例項的識別符號SID)
export ORACLE_SID=lenovo
echo $ORACLE_SID
mkdir -p /u01/app/oracle/admin/lenovo/adump
orapwd file="/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwLENOVO" password=oracle entries=30
Step 2: Ensure That the Required Environment Variables Are Set(確認環境變數的設定)
[oracle@redhat3 lenovo]$ mkdir datafile
[oracle@redhat3 lenovo]$ mkdir redolog
[oracle@redhat3 lenovo]$ pwd
/u01/app/oracle/oradata/lenovo
[oracle@redhat3 ~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
#Oracle Settings
export TMP=/tmp
export TMPDIR=/tmp
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=lenovo
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib:/usr/X11R6/lib/
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export LANG=C
umask 022
alias date='date +%Y-%m-%d%t%A%t%T '
Step 3: Choose a Database Administrator Authentication Method(決定資料庫管理員的認證方法)
[oracle@redhat3 bin]$ pwd
/u01/app/oracle/product/11.2.0/db_1/bin
[oracle@redhat3 bin]$ orapwd file=orapwdlenovo password=oracle entries=30
Step 4: Create the Initialization Parameter File(建立初始化的引數檔案資訊)
[oracle@redhat3 dbs]$ cat initlenovo.ora
db_name='LENOVO'
memory_target=808M
control_files = ('/u01/app/oracle/oradata/lenovo/controlfile/control01.ctl')
Step 6: Connect to the Instance(連線例項)
[oracle@redhat3 dbs]$ echo $ORACLE_SID
lenovo
[oracle@redhat3 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Nov 1 19:28:17 2016
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL>
Step 7: Create a Server Parameter File(建立spfile)
SQL> create spfile from pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initlenovo.ora';
Step 8: Start the Instance(啟動例項)
SQL> startup nomount
ORACLE instance started.
Total System Global Area 843456512 bytes
Fixed Size 2257920 bytes
Variable Size 494930944 bytes
Database Buffers 343932928 bytes
Redo Buffers 2334720 bytes
Step 9: Issue the CREATE DATABASE Statement(建立DATABASE的語句)
create_db.sql
CREATE DATABASE lenovo
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/lenovo/redolog/redo01a.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/app/oracle/oradata/lenovo/redolog/redo02a.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/app/oracle/oradata/lenovo/redolog/redo03a.log') SIZE 100M BLOCKSIZE 512
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/app/oracle/oradata/lenovo/datafile/system01.dbf' SIZE 325M REUSE
SYSAUX DATAFILE '/u01/app/oracle/oradata/lenovo/datafile/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u01/app/oracle/oradata/lenovo/datafile/users01.dbf'
SIZE 50M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/lenovo/datafile/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs1
DATAFILE '/u01/app/oracle/oradata/lenovo/datafile/undotbs01.dbf'
SIZE 100M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
SQL> @/home/oracle/create_db.sql
Database created.
Step 10: Create Additional Tablespaces(建立額外的表空間)
SQL>CREATE TABLESPACE zstest DATAFILE '/u01/app/oracle/oradata/lenovo/datafile/test01.dbf' SIZE 50M EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
SQL> select open_mode from v$database;
OPEN_MODE
----------------------------------------
READ WRITE
Step 11: Run Scripts to Build Data Dictionary Views(執行指令碼建立資料庫字典檢視)
SYSDBA使用者執行如下指令碼
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
@?/rdbms/admin/utlrp.sql
SYSTEM使用者執行如下指令碼
@?/sqlplus/admin/pupbld.sql