Search This Blog

Showing posts with label Oracle DBA. Show all posts
Showing posts with label Oracle DBA. Show all posts

Saturday, September 10, 2011

How to delete/remove Oracle Enterprise Manager Console in 11GR2

I received email for asking "how to delete/remove OEM console on 11gr2 windows platform"
How to drop ORACLE ENTERPRISE MANAGER repository and configuration files manually on 11gr2

Step
1. delete DB control repository objects manually
logon as sysdba user
and execute following sql statement
exec DBMS_AQADM.DROP_QUEUE_TABLE(queue_table=>>'SYSMAN.MGMT_NOTIFY_QTABLE',force =>>TRUE);

2. login sys or system and drop SYSMAN AND MANAGEMENT OBJECTS
 SHUTDOWN IMMEDIATE;
 STARTUP RESTRICT;
 EXEC sysman.emd_maintenance.remove_em_dbms_jobs;
 EXEC sysman.setEMUserContext('',5);
 REVOKE dba FROM sysman;
 DECLARE
CURSOR c1 IS
SELECT owner, synonym_name name
FROM dba_synonyms
WHERE table_owner = 'SYSMAN';
BEGIN
FOR r1 IN c1 LOOP
IF r1.owner = 'PUBLIC' THEN
EXECUTE IMMEDIATE 'DROP PUBLIC SYNONYM '||r1.name;
ELSE
EXECUTE IMMEDIATE 'DROP SYNONYM '||r1.owner||'.'||r1.name;
END IF;
END LOOP;
END;
/
 DROP USER mgmt_view CASCADE;
 DROP ROLE mgmt_user;
 DROP USER sysman CASCADE;
 ALTER SYSTEM DISABLE RESTRICTED SESSION;


3. Delete DB control configuration files manually
Remove the following directories from your filesystem:
[ORACLE_HOME]/[hostname_sid]
[ORACLE_HOME]/oc4j/j2ee/OC4J_DBConsole_[hostname]_[sid]


If the dbcontrol is upgraded from lower version, for example, from 
11.1.0.2.0 to 11.2.0.1.0, then the following directory also needs to be removed from the file system.
[ORACLE_HOME]/[hostname_sid].upgrade
[ORACLE_HOME]/oc4j/j2ee/OC4J_DBConsole_[hostname]_[sid].upgrade

NOTE:  
On Windows you also need to delete the DB Console service:
- run regedit
- navigate to HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services
- locate the OracleDBConsole[sid] entry and delete it

Alternatively on Windows XP and Windows Server 2003 you can run the following from the command line: 
'sc delete [service_name]'
- where [service_name] is the DB Control service name (typically: OracleDBConsole[sid])
###############################################################################
C:\Documents and Settings\Administrator>>set oracle_sid=fakpropr

C:\Documents and Settings\Administrator>>sqlplus sys/manager1 as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Sat Sep 10 12:54:52 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>> exec DBMS_AQADM.DROP_QUEUE_TABLE(queue_table=>>'SYSMAN.MGMT_NOTIFY_QTABLE',f
orce =>>TRUE);

PL/SQL procedure successfully completed.

SQL>> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>> startup restrict;
ORACLE instance started.

Total System Global Area  945786880 bytes
Fixed Size                  1384328 bytes
Variable Size             637534328 bytes
Database Buffers          301989888 bytes
Redo Buffers                4878336 bytes
Database mounted.
Database opened.
SQL>> EXEC sysman.emd_maintenance.remove_em_dbms_jobs;

PL/SQL procedure successfully completed.

SQL>> EXEC sysman.setEMUserContext('',5);

PL/SQL procedure successfully completed.

SQL>> REVOKE dba FROM sysman;
REVOKE dba FROM sysman
*
ERROR at line 1:
ORA-01951: ROLE 'DBA' not granted to 'SYSMAN'


SQL>> DECLARE
  2  CURSOR c1 IS
  3  SELECT owner, synonym_name name
  4  FROM dba_synonyms
  5  WHERE table_owner = 'SYSMAN';
  6  BEGIN
  7  FOR r1 IN c1 LOOP
  8  IF r1.owner = 'PUBLIC' THEN
  9  EXECUTE IMMEDIATE 'DROP PUBLIC SYNONYM '||r1.name;
 10  ELSE
 11  EXECUTE IMMEDIATE 'DROP SYNONYM '||r1.owner||'.'||r1.name;
 12  END IF;
 13  END LOOP;
 14  END;
 15  /

PL/SQL procedure successfully completed.

SQL>> DROP USER mgmt_view CASCADE;

User dropped.

SQL>> DROP ROLE mgmt_user;

Role dropped.

SQL>> DROP USER sysman CASCADE;

User dropped.

SQL>> ALTER SYSTEM DISABLE RESTRICTED SESSION;

System altered.

IMPORTANT: delete the configuration files as mentioned in above Step# 3


C:\>>sc delete OracleDBConsolefakpropr
[SC] DeleteService SUCCESS

Thursday, September 8, 2011

Enterprise Manager is not able to connect to the database instance. The state of the components are listed below.

Today when i try to connect to Oracle Enterprise Manager in 11gr2 on widows server then got below message

Enterprise Manager is not able to connect to the database instance. The state of the components are listed below.
to check what could be the reason i check emoms.trc file located under
%ORACLE_HOME%\hostname.domainname_dbname\sysman\log\emoms.trc
and found the following error
[SystemThreadGroup-8] ERROR app.SessionObjectManager sessionDestroyed.128 - java.sql.SQLException: ORA-28000: the account is locked

java.sql.SQLException: ORA-28000: the account is locked

After that i checked locked account in db and found the following two account is locked.
1. SYSTEM / 2. SYSMAN
SQL> select username,account_status from dba_users
  2  where account_status ='LOCKED';

USERNAME                       ACCOUNT_STATUS
------------------------------ --------------------------------
SYSTEM                         LOCKED
SYSMAN                         LOCKED

Once i unlocked the account EM working fine

SQL> alter user SYSMAN account unlock;

User altered.

How to find Oracle Client & Oracle Server installed on machine

Well, the question "How to find oracle client and server installed on machine" is quite simple task... but for newbie it is still a tuff question.

Below are the way through we can find out
1.  Whenever you installed oracle client or server "system will create directories with their respective type called "CLIENT_1 for CLIENT & DB_1 for Server"
so we can check the above directories.
For Clients
D:\app\confadmin\product\11.1.0\client_1\

For DB Server
D:\app\Administrator\11.2.0\db

2.  there is a second way to check through opatch lsinventory
set oracle_home and go to oracle_home directory
execute opatch lsinventory

D:\app\confadmin\product\11.1.0\client_1\OPatch>set oracle_home=D:\APP\confadmin
\product\11.1.0\CLIENT_1

D:\app\confadmin\product\11.1.0\client_1\OPatch>opatch lsinventory
File Not Found
Invoking OPatch 11.1.0.6.0

Oracle Interim Patch Installer version 11.1.0.6.0
Copyright (c) 2007, Oracle Corporation.  All rights reserved.


Oracle Home       : D:\APP\confadmin\product\11.1.0\CLIENT_1
Central Inventory : C:\Program Files\Oracle\Inventory
   from           : n/a
OPatch version    : 11.1.0.6.0
OUI version       : 11.1.0.6.0
OUI location      : D:\APP\confadmin\product\11.1.0\CLIENT_1\oui
Log file location : D:\APP\confadmin\product\11.1.0\CLIENT_1\cfgtoollogs\opatch\
opatch2011-09-08_08-58-17AM.log

Lsinventory Output file location : D:\APP\confadmin\product\11.1.0\CLIENT_1\cfgt
oollogs\opatch\lsinv\lsinventory2011-09-08_08-58-17AM.txt

--------------------------------------------------------------------------------

Installed Top-level Products (1):

Oracle Client                                                        11.1.0.6.0
There are 1 products installed in this Oracle Home.


There are no Interim patches installed in this Oracle Home.

--------------------------------------------------------------------------------


OPatch succeeded.


For Database Server
D:\app\Administrator\11.2.0\db\OPatch>opatch lsinventory
Invoking OPatch 11.2.0.1.6

Oracle Interim Patch Installer version 11.2.0.1.6
Copyright (c) 2011, Oracle Corporation.  All rights reserved.


Oracle Home       : D:\app\Administrator\11.2.0\db
Central Inventory : C:\Program Files\Oracle\Inventory
   from           : n/a
OPatch version    : 11.2.0.1.6
OUI version       : 11.2.0.2.0
Log file location : D:\app\Administrator\11.2.0\db\cfgtoollogs\opatch\opatch2011
-09-08_08-49-24AM.log

Lsinventory Output file location : D:\app\Administrator\11.2.0\db\cfgtoollogs\op
atch\lsinv\lsinventory2011-09-08_08-49-24AM.txt

--------------------------------------------------------------------------------

Installed Top-level Products (1):

Oracle Database 11g                                                  11.2.0.2.0
There are 1 products installed in this Oracle Home.

3.  there is a third way to check through oracle services 
If oracle database services is created , it mean ORACLE SERVER is installed

but if you installed only oracle software then you will not find oracle database services.

Wednesday, September 7, 2011

Oracle Database Physical Limits from Oracle 7 to Oracle 11gr2 --- You may not know

Dear All,
Today i thought to write something about Oracle Database Physical Limits ... from Oracle 7 to Oracle 11gr2 what are the changes happened and what are the new features introduced.

Lets start with Oracle 7 Version
Item
Type
Limit
blocks (Oracle7)
minimum in initial extent
2 blocks (automatically enforced)
maximum
232 -1 (up to 4 terabytes, depending on block size)
control files
number of control files
one minimum: 2 or more strongly recommended on separate devices
size of a control file
typically 50..200Kb, depending on database creation options; maximum is O/S-dependent
database files
system
1022 or value of DB_FILES in INIT.ORA, or limited by value of MAXDATAFILES in CREATE DATABASE. Less on some operating systems.
database file size
minimum
no absolute limit except for first file whose minimum size is 2 MB
maximum
O/S dependent, typically 16 million Oracle7 blocks
redo log files
database
255 or value for LOG_FILES in INIT.ORA, or by MAXLOGFILES in CREATE DATABASE. Ultimately, an operating system limit.
redo log file size
minimum
50 Kbytes
tablespaces
database
no limit
Above are the basic list of all items started with Oracle 7 , now we check changes in each higher release of oracle.

Oracle 8i
In this release the below new item introduced and  improved.
MAXEXTENTS 
Default value 
Derived from tablespace default storage or DB_BLOCK_SIZE initialization parameter. 
Maximum 
Unlimited 
Database extents 
Maximum 
2 GB, regardless of the maximum file size allowed by the operating system. 

Oracle 9ir1
There is no changes between oracle 8i to 9ir1.

Oracle 9ir2
There is no changes between oracle 9ir1 to 9ir2.

Oracle 10gr1
In this release the below new item introduced and  improved.
Database extents
Maximum per dictionary managed tablespace
4 GB * physical block size (with K/M modifier); 4 GB (without K/M modifier)
Maximum per locally managed (uniform) tablespace
2 GB * physical block size (with K/M modifier); 2 GB (without K/M modifier)
Bigfile Tablespaces
Number of blocks
232 (4 GB) blocks
Smallfile (traditional) Tablespaces
Number of blocks
222 (4 MB) blocks
Oracle 10gr2
In this release the below new item introduced and improved.
Bigfile Tablespaces
Number of blocks
A bigfile tablespace contains only one datafile or tempfile, which can contain up to approximately 4 billion ( 232 ) blocks. The maximum size of the single datafile or tempfile is 128 terabytes (TB) for a tablespace with 32K blocks and 32TB for a tablespace with 8K blocks.
Smallfile (traditional) Tablespaces
Number of blocks
A smallfile tablespace is a traditional Oracle tablespace, which can contain 1022 datafiles or tempfiles, each of which can contain up to approximately 4 million (222) blocks.
External Tables file
Maximum size
Dependent on the operating system.
An external table can be composed of multiple files.
Oracle 11gr1
There is no changes between oracle 10gr2 to 11gr1.

Oracle 11gr2
There is no changes between oracle 11gr1 to 11gr2.


Oracle 11gr2 

Physical Database Limits

ItemType of LimitLimit Value
Database Block SizeMinimum2048 bytes; must be a multiple of operating system physical block size
Database Block SizeMaximumOperating system dependent; never more than 32 KB
Database BlocksMinimum in initial extent of a segment2 blocks
Database BlocksMaximum per datafilePlatform dependent; typically 222 - 1 blocks
ControlfilesNumber of control files1 minimum; 2 or more (on separate devices) strongly recommended
ControlfilesSize of a control fileDependent on operating system and database creation options; maximum of 25,000 x (database block size)
Database filesMaximum per tablespaceOperating system dependent; usually 1022
Database filesMaximum per database65533May be less on some operating systems
Limited also by size of database blocks and by the DB_FILES initialization parameter for a particular instance
Database extentsMaximum per dictionary managed tablespace4 GB * physical block size (with K/M modifier); 4 GB (without K/M modifier)
Database extentsMaximum per locally managed (uniform) tablespace2 GB * physical block size (with K/M modifier); 2 GB (without K/M modifier)
Database file sizeMaximumOperating system dependent. Limited by maximum operating system file size; typically 222 or 4 MB blocks
MAXEXTENTSDefault valueDerived from tablespace default storage or DB_BLOCK_SIZE initialization parameter
MAXEXTENTSMaximumUnlimited
Redo Log FilesMaximum number of logfilesLimited by value of MAXLOGFILES parameter in the CREATE DATABASE statementControl file can be resized to allow more entries; ultimately an operating system limit
Redo Log FilesMaximum number of logfiles per groupUnlimited
Redo Log File SizeMinimum size4 MB
Redo Log File SizeMaximum SizeOperating system limit; typically 2 GB
TablespacesMaximum number per database64 KNumber of tablespaces cannot exceed the number of database files because each tablespace must include at least one file
Bigfile TablespacesNumber of blocksA bigfile tablespace contains only one datafile or tempfile, which can contain up to approximately 4 billion ( 232 ) blocks. The maximum size of the single datafile or tempfile is 128 terabytes (TB) for a tablespace with 32 K blocks and 32 TB for a tablespace with 8 K blocks.
Smallfile (traditional) TablespacesNumber of blocksA smallfile tablespace is a traditional Oracle tablespace, which can contain 1022 datafiles or tempfiles, each of which can contain up to approximately 4 million (222) blocks.
External Tables fileMaximum sizeDependent on the operating system.An external table can be composed of multiple files.

Tuesday, September 6, 2011

Manual Delete/Drop Database in 11gr2 via command line

There is two option to delete/drop database in oracle via DBCA or COMMAND line.

How to drop database via command line
Step:
1.  connect with sysdba user 
SQL> startup mount
ORACLE instance started.

Total System Global Area  150667264 bytes
Fixed Size                  1382112 bytes
Variable Size              92277024 bytes
Database Buffers           50331648 bytes
Redo Buffers                6676480 bytes
Database mounted.
SQL> alter system enable restricted session;

System altered.

SQL> drop database;

Database dropped.

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Pr
oduction
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Important Point:
1. Database must be closed
2. database must be in restricted mode
3. drop database command will delete ORADATA FILES (control/redo/datafile and SPFILE)
4. archivelog and rman backup can be deleted via rman command
5. drop database will not delete any files on raw disk. we need to delete manually
6. registry entry need to delete manually

write me email in case of any queries at askdbataj


Monday, September 5, 2011

Automatic Workload Respository (AWR) 11gr2

On the OTN forums i used to see a lot of thread about AWR basic questions. like "how to generate , how to analyze etc etc".
It is worth to write on AWR today.

FAQ's
1. What is AWR reports?
AWR = Automatic workload respository introduced in 10gr1 to tune oracle database. it is a advance version of old snapshot method.
Automatic Workload Repository (AWR) is a repository of historical performance data that includes cumulative statistics for the system, sessions, individual SQL statements, segments, and services. These statistics are the foundation of performance tuning. By automating the gathering of database statistics for problem detection and tuning, AWR serves as the foundation for database self-management.


2. How to use or generate AWR reports?
AWR reports will generate automatically by oracle database in every 1 hour interval and retained in the database for 8 days.

If you want to generate AWR report manually then use the following steps
There few scripts needs to be run on SQL prompt to generate AWR report manually.
all the scripts is located under $ORACLE_HOME/rdbms/admin directory


SQL> conn system/oracle@db01



Connected.


SQL> --to generate AWR report there is a awrrpt.sql script needs to be run.


SQL> @D:\app\Administrator\11.2.0\db\RDBMS\ADMIN\awrrpt.sql


If database is RAC then run the following scripts
SQL>@%ORACLE_HOME%/rdbms/admin/awrgrpt.sql

If you have multiple instance configured on the same host and want to generate AWR report for the specific instance then run the following scripts
SQL>@%ORACLE_HOME%/rdbms/admin/awrrpti.sql

Generating AWR report on RAC for specific database instance
SQL>@%ORACLE_HOME%/rdbms/admin/awrgrpti.sql


Generating AWR report on RAC database
SQL>@%ORACLE_HOME%/rdbms/admin/awrgdrpt.sql


Generating AWR report for specific instance
SQL>@%ORACLE_HOME/rdbms/admin/awrddrpi.sql

Generating AWR report for specific instance on RAC

SQL>@%ORACLE_HOME/rdbms/admin/awrgdrpi.sql


Generating AWR report for an SQL statement
SQL>@%ORACLE_HOME%/rdbms/admin/awrsqrpt.sql

Generating AWR report for an SQL statement for specific instance
SQL>@%ORACLE_HOME%/rdbms/admin/awrsqrpti.sql

NOTE: you can get the SQL ID from V$SQL database view.



Generating AWR report to compare periods reports
We can compare the two different periods reports to analyze database bottleneck.
there is a scripts needs to be run called awrddrpt.sql

SQL>@%ORACLE_HOME%/rdbms/admin/awrddrpt.sql


Generating AWR report to compare periods reports for RAC


List of all AWR scripts.
D:\app\Administrator\11.2.0\db\RDBMS\ADMIN>dir awr*.sql

Volume in drive D is OraHome
Volume Serial Number is 50E3-4204

Directory of D:\app\Administrator\11.2.0\db\RDBMS\ADMIN

01-12-2006 07:31 PM 1,189 awrblmig.sql
This script will migrate the baseline data on a pre-11g database to the 11g database.

23-05-2005 08:13 PM 21,618 awrddinp.sql

13-05-2009 07:08 PM 7,600 awrddrpi.sql
This script will compare period reports for specific instance.

27-05-2005 08:22 PM 2,069 awrddrpt.sql
This script will compare period reports.

24-03-2009 10:38 AM 11,490 awrextr.sql
This script extract AWR details from EXPORT DATA PUMP FILE, suppose if you want to export AWR details from PROD and import in TEST db, in that case you can use this scripts (you need to give DATA PUMP DIRECTORY AND IT WILL WORK ONLY WITH DATAPUMP Utilities)

13-03-2008 04:01 PM 17,051 awrgdinp.sql
13-05-2009 07:08 PM 7,551 awrgdrpi.sql
This script compare period report for RAC database on specific instance.

29-04-2009 05:53 PM 1,958 awrgdrpt.sql
This script compare period report for RAC database.

13-03-2008 04:01 PM 7,719 awrginp.sql
29-04-2009 05:53 PM 1,578 awrgrpt.sql
This script generate AWR report for RAC database.

13-03-2008 04:01 PM 6,526 awrgrpti.sql
This script generate AWR report for RAC database on specific instance.

01-09-2004 06:38 PM 50,507 awrinfo.sql
This is one of the most important scripts that DBA needs to run frequenctly and check the followings :
this script will give us the below information:
1. SYSAUX space occupied by AWR reports in the particular tablespace
2. SYSAUX occupants 
3. SYSAUX usage (unregistered schemas)
4. Size estimated for AWR snapshots
5. Space usage by AWR components
6. And many more info... just run and read it.
This scripts must be run with SYSDBA user.

05-01-2005 03:25 PM 2,542 awrinpnm.sql
03-03-2006 05:47 PM 8,901 awrinput.sql
15-07-2009 10:20 AM 10,736 awrload.sql
This script will LOAD awr report from exported dumpfile to the target system. once you execute the script , then it will create the AWR staging schema to load awr report after loading report will be transffered to SYS schema. (DATA PUMP DIRECTORY required)

24-10-2003 02:20 PM 2,069 awrrpt.sql
This script will generate AWR report

18-04-2005 01:00 PM 7,801 awrrpti.sql
This script will generate AWR report on specific instance

05-01-2005 03:25 PM 6,919 awrsqrpi.sql
This script will generate AWR report on specific instance for SQL statement.

05-01-2005 03:25 PM 1,528 awrsqrpt.sql
This script will genearate AWR report for SQL statement.

By default system create the snapshot every hour but if you want to create snapshot on a specific time then use the following procedure.

To create snapshot manually

SQL> conn sys/oracle@db01 as sysdba

Connected.


SQL> begin
2 DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT ();
3 end;
4 /
PL/SQL procedure successfully completed.

If you want to drop snapshot manually
BEGIN

DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE (low_snap_id => 22,
High_snap_id => 32, dbid => 3310949047);
END;
/

To modify default retention settings of snapshot.
BEGIN

DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS( retention => 43200,
interval => 30, topnsql => 100, dbid => 3310949047);
END;
/



In case of any doubt write me email at askdbataj


Thursday, September 1, 2011

How to change the DBID,DBNAME Using NID utility in version 11gr2

How to change the DBID,DBNAME Using NID utility in version 11gr2
How to change the DBID,DBNAME Using NID utility in version 11gr2
OS win 2003
Ora: 11gr2
OLD DBNAME/ID = DAY/3579108225 ( you can check the dbid with the following SQL query)
NEW DBNAME/ID = NIGHT/
SQL> select dbid from v$database;
      DBID
----------
3579108225
Step:
1. cold backup of database
2. Bring database in mount stage
3. set oracle_home
4. check tnsping / lsrnctl status ( make sure tnsnames.ora and listener.ora file configured with OLD_DB).
5. drop dbconsole (if configured)
6. issue NID utility
7. change the db_name in pfile/spfile
8. bring database in mount stage
9. open database in resetlogs 
10. recreate password
11. configure tnsnames.ora file with the new db name.
12. rename GLOBAL DATABASE NAMES (if configured)
13. recreate database service via ORADIM utility (windows specific steops)
14. full backup of database (after rename dbname or dbid)
Details
1. Cold backup
C:\>set oracle_sid=day
C:\>sqlplus sys/oracle as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Thu Sep 1 11:29:14 2011
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> host xcopy D:\app\Administrator\oradata\day\*.* f:\tmp\
D:\app\Administrator\oradata\day\CONTROL01.CTL
D:\app\Administrator\oradata\day\CONTROL02.CTL
D:\app\Administrator\oradata\day\REDO01.LOG
D:\app\Administrator\oradata\day\REDO02.LOG
D:\app\Administrator\oradata\day\REDO03.LOG
D:\app\Administrator\oradata\day\SYSAUX01.DBF
D:\app\Administrator\oradata\day\SYSTEM01.DBF
D:\app\Administrator\oradata\day\TEMP01.DBF
D:\app\Administrator\oradata\day\UNDOTBS01.DBF
D:\app\Administrator\oradata\day\USERS01.DBF
10 File(s) copied
SQL> --bring database in mount stage
SQL> startup  mount
ORACLE instance started.
Total System Global Area  535662592 bytes
Fixed Size                  1384752 bytes
Variable Size             293605072 bytes
Database Buffers          234881024 bytes
Redo Buffers                5791744 bytes
Database mounted.
SQL> --set ORACLE_HOME
SQL> host set ORACLE_HOME=D:\app\Administrator\11.2.0\db
SQL> --configure listner and tnsnames.ora for OLD DB name so we can connect with
SQL> --tnsentry
SQL> --you can check the tns configure via connecting to db with tns entry
SQL> -- for drop dbconsole we need to open the database.
SQL> alter database open;
Database altered.
SQL> --drop dbconsole
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Pr
oduction
With the Partitioning, OLAP, Data Mining and Real Application Testing options

C:\>cd d:\app\Administrator\11.2.0\db\BIN
C:\>set ORACLE_HOME=d:\app\Administrator\11.2.0\db\
C:\>set oracle_sid=DAY
C:\>emca -deconfig dbcontrol db -repos drop
STARTED EMCA at Sep 1, 2011 12:16:32 PM
EM Configuration Assistant, Version 11.2.0.0.2 Production
Copyright (c) 2003, 2005, Oracle.  All rights reserved.
Enter the following information:
Database SID: DAY
Listener port number: 1521
Password for SYS user:
Password for SYSMAN user:
----------------------------------------------------------------------
WARNING : While repository is dropped the database will be put in quiesce mode.
----------------------------------------------------------------------
Do you wish to continue? [yes(Y)/no(N)]: Y
Sep 1, 2011 12:16:44 PM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at D:\app\Administrator\cfgtoollogs\emca\da
y\emca_2011_09_01_12_16_32.log.
Sep 1, 2011 12:16:44 PM oracle.sysman.emcp.EMDBPreConfig performDeconfiguration
WARNING: EM is not configured for this database. No EM-specific actions can be p
erformed. Some of the possible reasons may be:
 1) EM is configured with different hostname then physical host. Set environment
 variable ORACLE_HOSTNAME= and re-run EMCA script
 2) ORACLE_HOSTNAME is set. Unset it and re-run EMCA script
Sep 1, 2011 12:16:44 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Dropping the EM repository (this may take a while) ...
Sep 1, 2011 12:23:52 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully dropped
Enterprise Manager configuration completed successfully
FINISHED EMCA at Sep 1, 2011 12:23:53 PM
SQL> --after dropping dbconsole close the database
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  535662592 bytes
Fixed Size                  1384752 bytes
Variable Size             301993680 bytes
Database Buffers          226492416 bytes
Redo Buffers                5791744 bytes
Database mounted.
SQL> host NID target=sys/oracle@day DBNAME=NIGHT
DBNEWID: Release 11.2.0.2.0 - Production on Thu Sep 1 12:36:01 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to database DAY (DBID=3579108225)

Connected to server version 11.2.0

Control Files in database:
    D:\APP\ADMINISTRATOR\ORADATA\DAY\CONTROL01.CTL
    D:\APP\ADMINISTRATOR\ORADATA\DAY\CONTROL02.CTL

Change database ID and database name DAY to NIGHT? (Y/[N]) => Y

Proceeding with operation
Changing database ID from 3579108225 to 2106096690
Changing database name from DAY to NIGHT
    Control File D:\APP\ADMINISTRATOR\ORADATA\DAY\CONTROL01.CTL - modified
    Control File D:\APP\ADMINISTRATOR\ORADATA\DAY\CONTROL02.CTL - modified
    Datafile D:\APP\ADMINISTRATOR\ORADATA\DAY\SYSTEM01.DB - dbid changed, wrote
new name
    Datafile D:\APP\ADMINISTRATOR\ORADATA\DAY\SYSAUX01.DB - dbid changed, wrote
new name
    Datafile D:\APP\ADMINISTRATOR\ORADATA\DAY\UNDOTBS01.DB - dbid changed, wrote
 new name
    Datafile D:\APP\ADMINISTRATOR\ORADATA\DAY\USERS01.DB - dbid changed, wrote n
ew name
    Datafile D:\APP\ADMINISTRATOR\ORADATA\DAY\TEMP01.DB - dbid changed, wrote ne
w name
    Control File D:\APP\ADMINISTRATOR\ORADATA\DAY\CONTROL01.CTL - dbid changed,
wrote new name
    Control File D:\APP\ADMINISTRATOR\ORADATA\DAY\CONTROL02.CTL - dbid changed,
wrote new name
    Instance shut down

Database name changed to NIGHT.
Modify parameter file and generate a new password file before restarting.
Database ID for database NIGHT changed to 2106096690.
All previous backups and archived redo logs for this database are unusable.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.

C:\>sqlplus sys/oracle as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Thu Sep 1 12:38:18 2011
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
Connected to an idle instance.

SQL> --change the new db name in the pfile and create spfile from pfile;
SQL> create pfile from spfile;
File created.
SQL> --change name in pfile
SQL> create spfile from pfile;
File created.
SQL> --now startup db in mount stage
SQL> startup mount
ORACLE instance started.

Total System Global Area  535662592 bytes
Fixed Size                  1384752 bytes
Variable Size             301993680 bytes
Database Buffers          226492416 bytes
Redo Buffers                5791744 bytes
Database mounted.
SQL> --open database in resetlogs
SQL> alter database open resetlogs;

Database altered.

SQL> --recreate password file via ORAPWD utility
SQL> host orapwd file=D:\app\Administrator\11.2.0\db\database\orapwdnight.ora pa
ssword=oracle entries=5

SQL> --configure TNSNAMES.ORA file for new db name
SQL> --$ORACLE_HOME/network/admin/TNSNAMES.ORA
SQL> --rename GLOBAL DATABASE NAME
SQL> --recreate oracle service via ORADIM utility (on windows only)
SQL> host oradim -new -sid NIGHT -startmode manual
Instance created.
SQL> --check the new dbid and db name
SQL> select dbid,name from v$database;

      DBID NAME
---------- ---------
2106096690 NIGHT