You are on page 1of 4

##################################################

# How to create Oracle9i database on Linux or Unix


##################################################
# login to Unix server as user oracle
# create directories for admin files
$ cd $ORACLE_HOME/admin
$ mkdir dbname
$ cd dbname
$ mkdir bdump cdump create pfile udump
# create directories for database files
$ cd /oradisk
$ mkdir oracle
$ cd oracle
$ mkdir oradata
$ cd oradata
$ mkdir dbname
# create initialization parameter file init.ora in directory $ORACLE_HOME/admin/
dbname/pfile
# make copy of the default file $ORACLE_HOME/dbs/init.ora and change the paramet
ers
# create the password file orapwdbname in directory $ORACLE_HOME/dbs
$ orapwd file=$ORACLE_HOME/dbs/orapwdbname password=syspassword entries=10
# connect to the non-existing instance and start it
$ ORACLE_SID=dbname
$ cd $ORACLE_HOME/admin/dbname/create
$ sqlplus /nolog
> connect / as sysdba
> startup nomount pfile='/ora0/oracle/ora92/admin/dbname/pfile/init.ora'
-- create database
> create database dbname
user sys identified by syspassword
user system identified by systempassword
logfile
group 1 ('/oradisk/oracle/oradata/dbname/redo01.log') size 100m,
group 2 ('/oradisk/oracle/oradata/dbname/redo02.log') size 100m,
group 3 ('/oradisk/oracle/oradata/dbname/redo03.log') size 100m
maxlogfiles 5
maxlogmembers 5
maxloghistory 1
maxdatafiles 100
maxinstances 1
character set AL32UTF8
national character set AL16UTF16
datafile '/oradisk/oracle/oradata/dbname/system01.dbf'
size 400m reuse autoextend on next 10m maxsize 500m
extent management local
default temporary tablespace temp
tempfile '/oradisk/oracle/oradata/dbname/temp01.dbf'
size 200m reuse autoextend on next 10m maxsize 2000m
undo tablespace undotbs1
datafile '/oradisk/oracle/oradata/dbname/undotbs01.dbf'
size 200m reuse autoextend on next 100m maxsize 8000m
;
-- create user tablespaces
> create tablespace app_data
logging
datafile '/oradisk/oracle/oradata/dbname/app_dat01.dbf'
size 8000m reuse
extent management local
segment space management auto
;
> alter tablespace app_data
add datafile '/oradisk/oracle/oradata/dbname/app_dat02.dbf'
size 8000m reuse
;
> create tablespace app_indx
logging
datafile '/oradisk/oracle/oradata/dbname/app_ind01.dbf'
size 8000m reuse
extent management local
segment space management auto
;
> alter tablespace app_indx
add datafile '/oradisk/oracle/oradata/dbname/app_ind02.dbf'
size 8000m reuse
;
> create tablespace ext_data
logging
datafile '/oradisk/oracle/oradata/dbname/ext_dat01.dbf'
size 2000m reuse autoextend on next 100m maxsize 4000m
extent management local
segment space management auto
;
> create tablespace ext_indx
logging
datafile '/oradisk/oracle/oradata/dbname/ext_ind01.dbf'
size 2000m reuse autoextend on next 100m maxsize 4000m
extent management local
segment space management auto
;
-- run catalog scripts
> spool catalog
> @$ORACLE_HOME/rdbms/admin/catalog.sql
> spool off
> spool catproc
> @$ORACLE_HOME/rdbms/admin/catproc.sql
> spool off
-- Login as System User
$ sqlplus SYSTEM/SYSTEM_PASSWORD
SQL> @?/sqlplus/admin/pupbld.sql

-- Run the script to change the dictonary tablespace to local tablepspace


SQL> EXECUTE DBMS_SPACE_ADMIN.TABLESPACE_MIGRATE_TO_LOCAL('SYSTEM');
-- create server parameter file
> create spfile='/ora0/oracle/ora92/dbs/spfiledbname.ora'
from pfile='/ora0/oracle/ora92/admin/dbname/pfile/init.ora';
-- restart the database
> shutdown
> startup
> exit
# make sure the database starts automaticaly after the reboot of the server
$ vi /etc/oratab
# add line for a new database
dbname:/ora0/oracle/ora92:Y
# add alias for a new database into tnsnames
$ vi $ORACLE_HOME/network/admin/tnsnames.ora
dbname =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = servername)(PORT = 1521))
)
(CONNECT_DATA =
(SID = dbname)
(SERVER = DEDICATED)
)
)
# finalize the database and create some good stuff
$ sqlplus /nolog
-- gather stats for SYS schema - good for performance
> conn sys/syspassword@dbname as sysdba
> execute dbms_stats.gather_schema_stats ('SYS', cascade=>TRUE, degree=>20)
-- create PRODUCT_USER_PROFILE
> conn system/systempassword@dbname
> @$ORACLE_HOME/sqlplus/admin/pupbld.sql
-- create application role and user
> create role approle;
> create user appuser
identified by userpassword
default tablespace app_data
temporary tablespace temp
profile default
account unlock;
> grant connect to appuser;
> grant resource to appuser;
> grant approle to appuser;
> alter user appuser default role all;
> grant create any view to appuser;
> grant create any trigger to appuser;
> grant create any procedure to appuser;
> grant execute any procedure to appuser;
> alter user appuser
quota unlimited on app_data
quota unlimited on app_indx;
> exit