oracle 10g 手工建庫

Oracle 手工建庫

1、安裝數據庫選擇只安裝數據庫軟件,不創建數據庫。

如果已經安裝數據庫,手工刪除數據庫

SQL>Shutdown immediate;

SQL>Startup mount;

SQL>Alter system enable restricted session;

SQL>Drop database;

2、設置環境變量

[oracle@oracle ~]$ cat /home/oracle/.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_BASE=/oracle/app

ORACLE_HOME=$ORACLE_BASE/oracle/product/10.2.0/db_1

ORACLE_SID=TEST

PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib

LANG=en_US.UTF-8

export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LD_LIBRARY_PATH LANG

環境變量生效

[oracle@oracle ~]$ source /home/oracle/.bash_profile

3、規劃表空間及數據文件路徑和大小

[oracle@oracle dbs]$ pwd

//oracle/app/oracle/product/10.2.0/db_1/dbs

[oracle@oracle dbs]$ ls

initdw.ora  init.ora

[oracle@oracle dbs]$ vim init$ORACLE_SID.ora

[oracle@oracle dbs]$ ls

initdw.ora  init.ora  initTEST.ora

[oracle@oracle dbs]$ cat initTEST.ora 

control_files = (/oracle/app/oradata/test/control1.ctl,/oracle/app/oradata/test/control2.ctl,/oracle/app/oradata/test/control3.ctl)

undo_management = AUTO

undo_tablespace = UNDOTBS1

db_name = test

db_unique_name = testl

db_block_size = 8192

sga_max_size = 320M

sga_target = 320M

4、創建密碼文件

[oracle@oracle dbs]$ orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=123456 force=y

5、建立所需目錄

[oracle@oracle app]$ pwd

/oracle/app

[oracle@oracle app]$ ls

oracle  oradata  oraInventory

[oracle@oracle app]$ mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump

[oracle@oracle app]$ mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/bdump

[oracle@oracle app]$  mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/pfile

[oracle@oracle app]$ mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/cdump

[oracle@oracle app]$ mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/dpdump

[oracle@oracle app]$ mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/udump

[oracle@oracle app]$ ls

admin  oracle  oradata  oraInventory

[oracle@oracle TEST]$ pwd

/oracle/app/admin/TEST

[oracle@oracle TEST]$ ls

adump  bdump  cdump  dpdump  pfile  udump

6、建立spfile

[oracle@oracle ~]$ sqlplus / as sysdba

SQL> startup nomount

ORACLE instance started.

Total System Global Area  335544320 bytes

Fixed Size                  1219304 bytes

Variable Size             104858904 bytes

Database Buffers          226492416 bytes

Redo Buffers                2973696 bytes

SQL> create spfile from pfile;

File created.

7、建立數據庫

[oracle@oracle ~]$  vi /home/oracle/createDB.sql

[oracle@oracle ~]$ cat createDB.sql 

create database test

logfile group 1 ('$ORACLE_BASE/oradata/test/redo01.log') size 100m,

        group 2 ('$ORACLE_BASE/oradata/test/redo02.log') size 100m,

        group 3 ('$ORACLE_BASE/oradata/test/redo03.log') size 100m

maxlogfiles 10

maxlogmembers 5

maxloghistory 5

maxdatafiles 100

maxinstances 1

character set zhs16gbk

national character set al16utf16

datafile '$ORACLE_BASE/oradata/test/system01.dbf' size 350m reuse autoextend on next 1m maxsize unlimited extent management local

sysaux datafile '$ORACLE_BASE/oradata/sysaux01.dbf' size 350m reuse autoextend on next 1m maxsize unlimited

default temporary tablespace temp01 tempfile '$ORACLE_BASE/oradata/test/temp01.dbf' size 50m reuse autoextend on next 1m maxsize 500m

undo tablespace undotbs1 datafile '$ORACLE_BASE/oradata/test/undotbs01.dbf' size 500m reuse autoextend on next 1m maxsize unlimited;

SQL> @/home/oracle/createDB.sql

Database created.

8、驗證數據庫

SQL> select name from v$database;

NAME

---------

TEST

9、建數據字典試圖和存儲過程包

SQL> @/oracle/app/oracle/product/10.2.0/db_1/rdbms/admin/catalog.sql

PL/SQL procedure successfully completed.

SQL> @/oracle/app/oracle/product/10.2.0/db_1/rdbms/admin/catproc.sql

10、查看數據庫進程。說明數據庫手工建庫成功。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章