Manual Creation of Database in Windows With Oracle 9i

You might also like

Download as doc
Download as doc
You are on page 1of 6

Manual Creation of database in windows with oracle 9i (Step-by-Step)

1. Open the command prompt and execute the command


sqlplus/nolog
2. Connect to the default database as sysdba in sql
prompt SQL>conn sys/oracle as sysdba you can see the
name of that database by executing
select name from v$database;
3. Start a windows service with internal password
oradim –new –sid <database name> intpwd <password> is
the syntax.

In this case I use to create Example1 service like,


oradim –new –sid Example1

4. Now open another command prompt and set oracle SID


as
set oracle_sid=Exampel1

5. Here is my initExample1.ora that I saved it in


d:\Example1\PFile\ folder. This is the static
parameter file that I used in my database creation

db_name = Example1
Log_archive_dest='D:\Example1\Archive\archive01.dbf'
log_archive_start=true
db_block_size=8192
db_cache_size=25165824
background_dump_dest=D:\Example1\bdump
core_dump_dest=D:\Example1\cdump
user_dump_dest=D:\Example1\ddump
control_files=
("D:\Example1\Control\control01.dbf","D:\Example\Contr
ol\control02.dbf")
compatible=9.2.0.0.0
java_pool_size=33554432
large_pool_size=3388608
shared_pool_size=50331648
undo_management=auto
undo_retention=10800
undo_tablespace=undotbs1

6. Now type following in your current command prompt


sqlplus/nolog and in sql prompt type conn
sys/ceylonlinux_suranga as sysdba then you should see
that you are connected to an idle instance.
7. Now start the instance in nomount mode as,
startup nomount
pfile=d:\Example1\Pfile\initExample1.ora
why are you starting the database in nomount mode ?
The reason is still we are not created control files.
“An instance would be started in the NOMOUNT stage
only during database creation or the re-creation of
control files.
8. This step is to create the database using dbca.sql
script that I saved in d:\Example1\DScript\ folder
appears follows ..

CREATE DATABASE Example1


LOGFILE GROUP 1('d:\Example1\Redo\redo01.log')
SIZE 100M,
GROUP 2('d:\Example1\Redo\redo02.log') SIZE 100M,
GROUP 3('d:\Example1\Redo\redo03.log') SIZE 100M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
CHARACTER SET US7ASCII
NATIONAL CHARACTER SET AL16UTF16
DATAFILE 'd:\Example1\DFile\system01.dbf' SIZE
325M
UNDO TABLESPACE UNDOTBS
DATAFILE 'd:\Example1\UFile\UNDOTBS.dbf'
SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE
UNLIMITED;
9. Execute dbca.sql
SQL>@D:\Example1\DScript\dbca.sql
10. Execute catalog.sql
SQL>@c:\oracle\ora92\rdbms\admin\catalog.sql
11. Execute catproc.sql SQL>
@c:\oracle\ora92\rdbms\admin\catproc.sql
12. Create SPfile from Pfile like as this creation:-
create spfile from pfile
=’D:\Example1\Pfile\initExample1.ora’

A.Take backup control file


Alter database backup controlfile to
‘D:\Example1\Backup\control.bak’
B.check the redo log file in a database :-
select * from v$log;
C.Switch the log file
Alter system switch logfile;
D.Check the log file used in database:-
Select * from v$logfile;
E. Add logfile in a group:-
Alter database add logfile group 4
‘D:\Example1\Redo\redo0103.log’ size 20m ;
F.Add Redo log file in created group
Alter database add logfile member
‘D:\Example1\Redo\redo0101.log’ to group 1;
After adding logfile then check status is :-
Select * from v$log;
Select * from v$logfile;
G. How to delete group in Redo log file
Alter database drop logfile group 1;
Select * from v$log;
H.How to delete group member in Redo log file:-
Alter database drop logfile member
‘D:\Example1\Redo\redo0205.log’;
I.Check the status of log_archive (By default set
False)
Show parameter log_archive;

J.Start the log _archive ;


Alter system set log_archive_start= true
scope=spfile;
K.Set the path of log_archive:
Alter system set
log_archive_dest=’D:\Example1\Archive\archive’
scope =spfile ;
L.Check status of Archive Mode:
Archive log list;
M.Alter the archive log
Alter system archive_log current;

Space Management in a Database


1.Check the used tablespace in a database:
Select * from V$tablespace;
2.Check the datafile in a database:
Select * from v$datafile;
Select file#, TS#, name, bytes from v$datafile;
3.Create the tablespace with locally management:
Create tablespace tbexample1 datafile
‘D:\Example1\Tfile\tbexample1.dbf’ size 100m
extent management local uniform size 20k;
4. Create the tablespace with dictionary management:
Create tablespace tbexample2 datafile
‘D:\Example1\Tfile\TBExample2.dbf’ size 100m
Extent management dictionary
Default storage (
Initial 20k
Next 40k
Pctincrease 50
Minextents 4
Maxextents 100
);
5.Check the tablespace status
select block_size bs, tablespace_name tns,
extent_management em, initial_extent ie,
next_extent ne,min_extents mine, max_extents maxe,
pct_increase ps
from dba_tablespaces ;
6.Check the tablespace status in particular define
tablespace name:
select block_size bs, tablespace_name tns,
extent_management em, initial_extent ie,
next_extent ne,min_extents mine, max_extents maxe,
pct_increase ps
from dba_tablespaces
where tablespace_name =TBExample1 ;
7.How to add the extra datafile in a define
tablespace:-
alter tablespace TBExample1 add datafile
'D:\Example1\TFile\TBExample11.dbf' size 100m
After above command run then check the tablespace
status:
a. Select * from v$tablespace;
b. Select ts#, name, file#, rfile#, from
v$datafile;
c. select ts#, name, file#, rfile# from v$datafile
where ts#=2
8.Read and Read write permission define by
following command:
alter tablespace TBExample1 read only;
alter tablespace TBExample1 read write;
8.Make online and offline Tablespace by following
command:
Alter tablespace TBExample2 offline;
Alter tablespace TBExample2 online;
9.How to drop the tablespace withcontents and
datafiles:
Drop tablespace tb1 including contents and
datafiles;
10.How to drop tablespace without contents and
datafiles:
Drop tablespace tb2;
11.How to create temporary tablespace in a database
and used this temporary datafile:
• create temporary tablespace temp1 tempfile
'D:\Example1\TFile\temp01.dbf' size 50m ;
• alter database default temporary tablespace
temp1 ;

A. How to create a table in define tablespace with


storage in a database:-
create table Example1
(
id number,
name char(30),
address varchar(30) )
tablespace TBExample1
storage (
initial 40k
next 40k
pctincrease 4
maxextents 100
)
B. Configure automatic Segment-Space Management
create tablespace TBExample3
datafile 'D:\Example1\Tfile\tbexample3,dbf' size
5m
extent management local uniform size 64k
segment space management auto ;
C. Query the DBA_SEGMENT

You might also like