Creating an Oracle 10g database from the command line only

This article is the successor to Creating an Oracle 9i database on NT from the command line only.

There are basically three ways to create an Oracle database:
• • •

Using the Database Configuration Assistant (DBCA) With the S ! create database state"ent Through u#grading an e$isting database%

This article focuses on the second o#tion% &t can be co"#leted on the co""and line only' that is' without any (U& tool% Also' the article is a bit biased towards Windows and its co""and #ro"#t (c"d%e$e: start->run)*cmd)%

Specifying the Instance's SID
There can be "ore than one Oracle instance on a single "achine% &n order to be able to distinguish these instances' Oracle uses a S&D (Syste" &dentifier) which is a string% The S&D can be set through the O+AC!,-S&D en.iron"ent .ariable%
D:\oracle\product0.1.0>set ORACLE SID!ORA10

Creating an Oracle Ser"ice
On Windows' each instance re/uires a Windows ser.ice% This ser.ice "ust first be created with oradi":
D:\oracle\product0.1.0\Db_1>oradim -new -sid %ORAC !_"#D% -intpwd $%"!CR!&'A""(ORD -startmode $ Instance created#

&t can be .erified that a Windows ser.ice was created by ty#ing ser)ices.msc into the console% A ser.ice na"ed OracleSer.iceO+A01 (O+A01 2 3O+AC!,-S&D3) will be found% Also' the startu# ty#e is manual as was re/uested by -startmode $% Oracle also created a #assword file under3O+AC!,-4O5,36database:
D:\oracle\product0.1.0\Db_1>dir database *olume in dri)e D +as no label. *olume "erial ,umber is C-!.--/.A

ora7 d:\oracle\databases\ora10\control05.'$ 11:1/ A$ 11:12 A$ 02:4.Director0 o1 D:\oracle\product0.oradba..e see"s to be the bare re/uired "ini"u"' you #robably also want do define bac<ground-du"#-dest'core-du"#-dest and user-du"#-dest% Starting the instance =ow' that we ha.1.'roduction on "at $ar 4 1/:04:14 5004 .ora< undo_mana=ement : auto db_name db_bloc>_si?e : ora10 : @1.ust to de"onstrate how the control files are found% Of course' you will add "ore init #ara"s into the init%ora file% D:\oracle\product0.0\Db_1>sAlplus 3nolo= "B C'lus: Release 10.'$ 6D#R> 6D#R> 6D#R> .5.0.'$ 02:4.1.% S9:&!.e created an Oracle ser.ora7 d:\oracle\databases\ora10\control02.ORA As can be seen' the S&D is in the #assword file7s na"e% Creating the initiali$ation parameter file When an Oracle instance starts u#' it re/uires either aninitiali8ation #ara"ter file (init%ora) or an S9:&!.5 The undo-"anage"ent #ara"eter is necessary if we want to use auto"atic undo "anage"ent% Although the abo.ora control_1iles : .0\Db_1\database 0230435004 0230435004 0230435004 0230435004 0230435004 02:4.d:\oracle\databases\ora10\control01.1. .S ha.1.e binary content and "ust be created fro" init%ora files% Therefore' the init%ora file (which is an ordianary te$t file) is created first% 4ere7s a minimal init%ora (under $ORACLE_HOME/dbs if it is Uni$' or %ORACLE_HOME%\database' if it is windows) . arc+i)e 2178-.0\Db_1\database\initORA10.e9e 574/0 '(DORA10.ice and the init%ora file' we7re ready to start the instance: D:\oracle\product0.0 .

b0tes This created the S(A (Syste" (lobal Area) and the bac<ground#rocesses% Creating the database We7re now ready to finally create the database: "B >create database ora10 lo=1ile =roup 1 .@57 500-7 Oracle. "B > connect s0s3$%"!CR!&'A""(ORD as s0sdba Connected to an idle instance.'1 national c+aracter set ut1@ data1ile GD:\oracle\databases\ora10\s0stem.GD:\oracle\databases\ora10\redo1.e to start the instance without "ounting (nomount) as there is no database we could "ount at the "o"ent% "B > startup nomount ORAC ! instance started.lo=G< si?e 10$ c+aracter set (!@#"O@@4.lo=G< si?e 10$7 =roup 2 .Cop0ri=+t .c< 1.GD:\oracle\databases\ora10\redo5. S !>9lus tells us that we7re connected to an idle instance% That "eans that it is not yet started% So' let7s start the instance% We ha. All ri=+ts reser)ed.db1G si?e 40$ autoe9tend on ne9t 10$ ma9si?e unlimited e9tent mana=ement local .GD:\oracle\databases\ora10\redo2. &otal "0stem Dlobal Area Ei9ed "i?e *ariable "i?e Database Fu11ers Redo Fu11ers 1125-/50@ b0tes 8@880@ b0tes /1@/-80@ b0tes 40221/-@ b0tes 5/51-.lo=G< si?e 10$7 =roup 5 .

ides a shortcut to refer to the O+AC!.sAl "B > IJ3rdbms3admin3catproc.db1G si?e 10$ de1ault temporar0 tablespace temp temp1ile GD:\oracle\databases\ora10\temp.-4O5.sAl catalog%s/l creates the data dictionary% cat#roc%s/l creates all structures re/uired for 9!?S !% .bsA) After the creation of the database' it can be "ounted and o#ened for use% Completing the D% creation &n order to co"#lete the db creation' the following scri#ts "ust be run as sys: • • 3O+AC!.db1G si?e 10$ autoe9tend on ne9t 10$ ma9si?e unlimited undo tablespace undo data1ile GD:\oracle\databases\ora10\undo.-4O5.-4O5.3?+D5BS?trace% &f an O+A)101@0: insufficient #ri.ileges is returned' that "eans "ost li<ely' that the current user is not in the dba grou# (on uni$)' or the O+A-DBA (windows)% &f the init%ora file is not at its default location or has not been found with the pfile attribute' an ORA-010 !" failure in #rocessing syste" #ara"eters and an LRM0010#" could not o#en #ara"eter file 7?a##l?oracle?#roduct?A%B%1%B?dbs?initad#db%ora7 error is issued% The create database co""and also e$ecutes a file whose na"e is deter"ined by the (hidden) init #ara"eter -init-s/l-file(which see"s to default to sAl.-4O5.s0sau9 data1ile GD:\oracle\databases\ora10\s0sau9.3?rdb"s?ad"in?cat#roc%s/l and S !>9lus #ro.db1G si?e 10$H &f so"ething goes wrong with the creation' Oracle will write an error into the alert%log% The alert log is nor"aly found in the directory that is s#ecified with the bac<ground-du"#-dest% &f this #ara"eter was not s#ecified (as is the case in our "ini"al init%ora)' the alert%log will be written into 3O+AC!.3?rdb"s?ad"in?catalog%s/l 3O+AC!. directory: the /uestion "ar< ($)% Therefore' these scri#ts can be called li<e so: "B > IJ3rdbms3admin3catalo=.

.-!O(-D."?install?init. Disconnection orced' the alert log should be consulted% This file "ost #robably contains a "ore desri#ti.-D.AT.ery early stage' there won7t be an alert%log% &n this case' the error will "ost #robably be found in a trace file in udu"# directory% .-:&!.sql which is a re/uire"ent to create triggers% The user syste" "ight also want to run$/s%lplus/admin/pupbld&s%l% #u#bld%s/l creates a table that allows to bloc< so"eone fro" using s/l #lus% "B > connect s0stem3mana=er "B > IJ3sAlplus3admin3pupbld Of course' tables#aces' users' tables and so on "ust be created according to the use of the database% Setting &p database to &sing 'a"a Also call CD?.AT.ST-n andDB-C+.catalog%s/l calls' for e$a"#le' catexp.e error "essage% &f the error occurs at a .er o#tion(D)% Oracle managed files +efer also to DB-C+." if you want to enable the ESer.a.ST for Oracle) "anaged files% Errors (hile creating database &f there is an error while the database is created' such as aORA-01092: ORACLE instance terminated.sql which is a re/uire"ent for e$#' or dbmsstdx.a.-O=!&=.