Sunday, June 27, 2010

Create Oracle Database manually using Command Line

I will be very brief on creation of new database using just command line and sqlplus.

(here is example on Oracle10g, but processes all same for other versions (though, it can be small different)

IN ORDER TO CREATE DB, WE NEED FOLLOWING STEPS TO DO:

1. directories have to be created

in C:\oracle\product\10.2.0\admin\ (adump, bdump, cdump, udump, pfile, dpdump)

in C:\oracle\product\10.2.0\flash_recovery_area folder<>

in C:\oracle\product\10.2.0\oradata\ folder

2. copy & edit existing pfile or create it (easiest way to get info from alert.log)

3. set env variable (set ORACLE_SID=NAME )

4. create pwd file => orapwd file=pwdTEST.ora password=test

5. create the db service (oradim -new -sid NAME)

6. sqlplus /nolog ... conn sys/test as sysdba or conn/as sysdba

connected to an idle

7. Start inctance in nomount mode (startup nomount pfile="C:\pfile.ora")

You can use this script to create DB:

create database

logfile group 1 ('C:\oracle\product\10.2.0\oradata\\redo1.log') size 10M,

group 2 ('C:\oracle\product\10.2.0\oradata\\redo2.log') size 10M,

group 3 ('C:\oracle\product\10.2.0\oradata\\redo3.log') size 10M

character set WE8ISO8859P1

national character set utf8

datafile 'C:\oracle\product\10.2.0\oradata\t0101\system.dbf'

size 50M

autoextend on

next 10M maxsize unlimited

extent management local

sysaux datafile 'C:\oracle\product\10.2.0\oradata\\sysaux.dbf'

size 10M

autoextend on

next 10M

maxsize unlimited

undo tablespace UNDOTBS1

datafile 'C:\oracle\product\10.2.0\oradata\\undo.dbf'

size 10M

default temporary tablespace temp

tempfile 'C:\oracle\product\10.2.0\oradata\\temp.dbf'

size 10M


Database created here.

Now we have to create DD catalog and PL/SQL catalog

run following scripts:

SQL> @$oracle_home\rdbms\admin\catalog.sql

SQL> @$oracle_home\rdbms\admin\catproc.sql

The user SYSTEM needs to run following script in order to block some users for using SQLPlus.

SQL> connect system/manager

SQL> @$oracle_home\sqlplus\admin\pupbld
For enabling JServer enable as following: @ $oracle_home\javavm\install\initjvm


In order your DBconsole to run, you need to create repository.

On command line:
emca -config dbcontrol db -repos create
SID: your_DB_name
lsnr port: 1521 (in most cases)
SYS pswd:
DBSNMP pswd:
SYSMAN pswd:



No comments:

Post a Comment