Monday, November 26, 2007

Starting up 10g EM console

1. Start the command prompt

2. Set the ORACLE SID to the instance on which the EM console needs to be started using the command like
Set ORACLE_SID=ocp

3. execute the command
emctl start dbcconsole

Above command results in following status message
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0
Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved.
http://PURUSHOTHAMAN:5504/em/console/aboutApplication
Starting Oracle Enterprise Manager 10g Database Control ...The OracleDBConsoleocp service is starting....
The OracleDBConsoleocp service was started successfully.


4. using IE / firefox open the page http://PURUSHOTHAMAN:5504/em

Thursday, November 22, 2007

Changing column data type with data

Recently my friend came with a stragne requirement. He has data in one of the columns which is date value but the table is wrongly created as varchar2 column. He wants to change the datatype from varchar2 to date.

Here it goes

First created a table like this

create table a(id number, dt1 varchar2(20));

Inserted some values into the table using following queries

insert into a values (4,'04/jul/2007')
insert into a values (1,'01/jul/2007')
insert into a values (2,'02/jul/2007')


Now create another column in the same table like this
alter table a add dt2 date


Now update the newly created column with the existing value using the query

update a set dt2=to_date(dt1)


Drop the varchar2 column from the table using
alter table a drop column dt1

Rename the newly created column
alter table a rename column dt2 to dt1

Manual Creation of 10g EM

Create the Database Control Repository and setup the OC4J Application Server
1. Now start the Oracle EM dbconsole Build Script
($ORACLE_HOME/bin/emca for Linux and $ORACLE_HOME\Bin\emca.bat for Windows).

2. Create the repository
$ emca -repos create
$ emca -config dbcontrol db
STARTED EMCA at Fri May 14 10:43:22 MEST 2004
Enter the following information about the databaseto be configured.
Listener port number: 1521
Database SID: AKI1
Service name: AKI1.WORLD
Email address for notification: martin.zahn@akadia.com
Email gateway for notification: mailhost
Password for dbsnmp: xxxxxxx
Password for sysman: xxxxxxx
Password for sys: xxxxxxx



After Creation the following message appears

AM oracle.sysman.emcp.EMConfig perform
INFO: DBConsole is started successfully
INFO: >>>>>>>>>>> The Enterprise Manager URL is http://akira:5500/em <<<<<<<<<<<>

Using browser the em can be connected at the URL http://akira:5500/em