Wednesday, September 25, 2013

DATABASE MONITORING

CHECK  BUFFER CACHE HIT RATIO


SELECT ROUND((1-(phy.VALUE / (cur.VALUE + con.VALUE)))*100,2) "Cache Hit Ratio"
FROM v$sysstat cur, v$sysstat con, v$sysstat phy
WHERE cur.name = 'db block gets'
AND con.name = 'consistent gets'
AND phy.name = 'physical reads'
/
 

CHECK DATAFILE SIZE


SELECT dp.tablespace_name
, df.file_name
, dp.block_size
, round(sum(df.maxbytes) /(1024*1024*1024),0) "Max_Size_GB"
, round(sum(df.bytes) /(1024*1024*1024),0) "Used_Size_GB"
FROM dba_tablespaces dp, dba_data_files df
WHERE dp.tablespace_name=df.tablespace_name
GROUP BY dp.tablespace_name, dp.block_size , df.file_name,df.maxbytes
ORDER BY dp.tablespace_name, df.file_name;


######################################################################

CHECK DATABASE SIZE 


SQL> select sum(bytes)/(1024*1024*1024) DB_SIZE_IN_GB from dba_data_files;

DB_SIZE_IN_GB
-------------
   5.93847656

////////////////////////////////////////

col "Database Size" format a20
col "Free space" format a20
col "Used space" format a20



select round(sum(used.bytes) / 1024 / 1024 / 1024 ) || ' GB' "Database Size"

, round(sum(used.bytes) / 1024 / 1024 / 1024 ) -
round(free.p / 1024 / 1024 / 1024) || ' GB' "Used space"
, round(free.p / 1024 / 1024 / 1024) || ' GB' "Free space"
from (select bytes
from v$datafile
union all
select bytes
from v$tempfile
union all
select bytes
from v$log) used
, (select sum(bytes) as p
from dba_free_space) free
group by free.p;


###################################################################

TOP  QUERIES IN LAST 5 MIN



SELECT * FROM

(select parsing_schema_name as users, sql_id, sql_text
,executions, disk_reads,buffer_gets
,DECODE (executions,0,0,round(((cpu_time/1000000)/executions),2)) "CPU Time"
,DECODE (executions,0,0,round(((elapsed_time/1000000)/executions),2)) "Elapsed Time"
FROM v$sqlarea
WHERE LAST_ACTIVE_TIME BETWEEN (sysdate - 5/1440) AND sysdate
AND parsing_schema_name NOT IN ('SYS', 'SYSTEM')
ORDER BY "CPU Time" DESC) x
WHERE rownum <=5; 

###############################################################3

TOP WAITING SESSION


SELECT sess.sid, sess.serial#, sess.username, sess.machine, SUM(ash.wait_time + ash.time_waited) wait_time
FROM v$active_session_history ash, v$session sess
WHERE ash.session_id = sess.sid
AND ash.sample_time BETWEEN (sysdate - 15/1440) AND sysdate
GROUP BY sess.sid, sess.serial#, sess.username, sess.machine
ORDER BY 4 DESC;


#####################################################################


KILL SESSION 


alter system kill session 'sid,serial#' ;

USING V$SESSION TO GET SID,SERIAL#

############################################################

TO CHECK HOW MANY TABLE IN USER 'HR'


select count(*) from dba_objects do where do.owner = 'HR'
and lower(object_type)=lower('Table');

####################################################################3




Friday, September 20, 2013

IMPORTANT SQL QUERY

TO DELETE DUPLICATE RECORD FROM TABLE
IF TABLE TEST CONTAIN DUPLICATE RECORD


DELETE FROM TEST WHERE ROWID NOT IN 
(SELECT MIN(ROWID) FROM TEST GROUP BY ID)

##################################################


CREATE DUPLICATE TABLE WITH DATA USING ANOTHER TABLE


CREATE TABLE TEST AS SELECT * FROM TEST1;

########################################################


CREATE DUPLICATE TABLE SAME SCHEMA AS USING ANOTHER 

TABLE


CREATE TABLE TEST AS SELECT * FROM TEST1 WHERE 1=2;




Tuesday, September 10, 2013

ORACLE DATABASE SILENT INSTALLATION ON LINUX

[oracle@localhost 10gR2-Linux4,5]$ ./runInstaller -record -destinationFile /oracle/myresponsef.rsp
Starting Oracle Universal Installer...

Checking installer requirements...

Checking operating system version: must be redhat-3, SuSE-9, redhat-4, UnitedLinux-1.0, asianux-1 or asianux-2
                                      Passed


All installer requirements met.

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-09-10_02-42-20PM. Please wait ...[oracle@localhost 10gR2-Linux4,5]$ Oracle Universal Installer, Version 10.2.0.1.0 Production
Copyright (C) 1999, 2005, Oracle. All rights reserved.


[oracle@localhost 10gR2-Linux4,5]$ ./runInstaller -silent -responseFile /oracle/myresponsef.rspStarting Oracle Universal Installer...

Checking installer requirements...

Checking operating system version: must be redhat-3, SuSE-9, redhat-4, UnitedLinux-1.0, asianux-1 or asianux-2
                                      Passed


All installer requirements met.

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-09-10_02-45-13PM. Please wait ...[oracle@localhost 10gR2-Linux4,5]$ Oracle Universal Installer, Version 10.2.0.1.0 Production
Copyright (C) 1999, 2005, Oracle. All rights reserved.

You can find a log of this install session at:
 /oracle/product/10.2.0/oraInventory/logs/installActions2013-09-10_02-45-13PM.log
.................................................................................................... 100% Done.

SEVERE:OUI-10029:You have specified a non-empty directory to install this product. It is recommended to specify either an empty or a non-existent directory. You may, however, choose to ignore this message if the directory contains Operating System generated files or subdirectories like lost+found.

[oracle@localhost 10gR2-Linux4,5]$
[oracle@localhost 10gR2-Linux4,5]$
[oracle@localhost 10gR2-Linux4,5]$
[oracle@localhost 10gR2-Linux4,5]$ ./runInstaller -silent -responseFile /oracle/myresponsef.rsp
Starting Oracle Universal Installer...

Checking installer requirements...

Checking operating system version: must be redhat-3, SuSE-9, redhat-4, UnitedLinux-1.0, asianux-1 or asianux-2
                                      Passed


All installer requirements met.

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-09-10_02-45-55PM. Please wait ...[oracle@localhost 10gR2-Linux4,5]$ Oracle Universal Installer, Version 10.2.0.1.0 Production
Copyright (C) 1999, 2005, Oracle. All rights reserved.

You can find a log of this install session at:
 /oracle/product/10.2.0/oraInventory/logs/installActions2013-09-10_02-45-55PM.log
.................................................................................................... 100% Done.


Loading Product Information
................................................................................................................... 100% Done.


Analyzing dependencies
.........................................................................
Starting execution of Prerequisites...
Total No of checks: 11

Performing check for CertifiedVersions
Checking operating system requirements ...
Expected result: One of redhat-3,redhat-4,SuSE-9,asianux-1,asianux-2
Actual Result: redhat-4
Check complete. The overall result of this check is: Passed


Check complete: Passed
=======================================================================
Performing check for Packages
Checking operating system package requirements ...
Checking for make-3.79; found make-1:3.81-3.el5.        Passed
Checking for binutils-2.14; found binutils-2.17.50.0.6-6.el5.   Passed
Checking for gcc-3.2; found gcc-4.1.2-42.el5.   Passed
Checking for libaio-0.3.96; found libaio-0.3.106-3.2.   Passed
Check complete. The overall result of this check is: Passed


Check complete: Passed
=======================================================================
Performing check for Kernel
Checking kernel parameters
Checking for semmsl=250; found semmsl=250.      Passed
Checking for semmns=32000; found semmns=32000.  Passed
Checking for semopm=100; found semopm=100.      Passed
Checking for semmni=128; found semmni=128.      Passed
Checking for shmmax=536870912; found shmmax=4294967295. Passed
Checking for shmmni=4096; found shmmni=4096.    Passed
Checking for shmall=2097152; found shmall=268435456.    Passed
Checking for file-max=65536; found file-max=205948.     Passed
Checking for VERSION=2.6.9; found VERSION=2.6.18-92.el5.        Passed
Checking for ip_local_port_range=1024 - 65000; found ip_local_port_range=1024 - 65000.  Passed
Checking for rmem_default=262144; found rmem_default=262144.    Passed
Checking for rmem_max=262144; found rmem_max=262144.    Passed
Checking for wmem_default=262144; found wmem_default=262144.    Passed
Checking for wmem_max=262144; found wmem_max=262144.    Passed
Check complete. The overall result of this check is: Passed


Check complete: Passed
=======================================================================
Performing check for GLIBC
Checking Recommended glibc version
Expected result: ATLEAST=2.3.2-95.27
Actual Result: 2.5-24
Check complete. The overall result of this check is: Passed


Check complete: Passed
=======================================================================
Performing check for TotalMemory
Checking physical memory requirements ...
Expected result: 922MB
Actual Result: 2024MB
Check complete. The overall result of this check is: Passed


Check complete: Passed
=======================================================================
Performing check for SwapSpace
Checking available swap space requirements ...
Expected result: 3036MB
Actual Result: 2996MB
Check complete. The overall result of this check is: Failed <<<<


Check complete: Failed <<<<
Problem: The system does not have the required swap space.
Recommendation: Make more swap space available to perform the install.

=======================================================================
Performing check for DetectIfDHCPAssignedIP
Checking Network Configuration requirements ...
Check complete. The overall result of this check is: Not executed <<<<


Check complete: Not executed <<<<
Recommendation: Oracle supports installations on systems with DHCP-assigned public IP addresses.  However, the primary network interface on the system should be configured with a static IP address in order for the Oracle Software to function properly.  See the Installation Guide for more details on installing the software on systems configured with DHCP.

=======================================================================
Performing check for OracleBase
Validating ORACLE_BASE location (if set) ...
Check complete. The overall result of this check is: Passed


Check complete: Passed
=======================================================================
Performing check for OracleHomeSpace
Checking Oracle Home path for spaces...
Check complete. The overall result of this check is: Passed


Check complete: Passed
=======================================================================
Performing check for DetectAnyInvalidASMHome
Checking for proper system clean-up....
Check complete. The overall result of this check is: Passed


Check complete: Passed
=======================================================================
Performing check for CompatibilityChecks
Checking for Oracle Home incompatibilities ....
Actual Result: NEW_HOME
Check complete. The overall result of this check is: Passed


Check complete: Passed
=======================================================================
PrereqChecks complete

.......................................... 100% Done.


-----------------------------------------------------------------------------
Summary
Global Settings
    Source: /home/oracle/10gR2-Linux4,5/10gR2-Linux4,5/stage/products.xml
    Oracle Home: /oracle/product/10.2.0/db_1 (OraDb10g_home1)
    Installation Type: Enterprise Edition
Product Languages
   English
Space Requirements
   / Required 2.03GB (includes 108MB temporary) : Available 28.83GB
New Installations (107 products)
   Oracle Database 10g 10.2.0.1.0
   Enterprise Edition Options 10.2.0.1.0
   Oracle Partitioning 10.2.0.1.0
   Oracle Spatial 10.2.0.1.0
   Oracle OLAP 10.2.0.1.0
   Oracle Enterprise Manager Console DB 10.2.0.1.0
   Oracle Net Services 10.2.0.1.0
   Oracle Database 10g 10.2.0.1.0
   Oracle Net Listener 10.2.0.1.0
   HAS Files for DB 10.2.0.1.0
   Oracle Internet Directory Client 10.2.0.1.0
   Oracle Call Interface (OCI) 10.2.0.1.0
   Oracle Programmer 10.2.0.1.0
   Oracle interMedia 10.2.0.1.0
   Enterprise Manager Agent Core 10.2.0.1.0
   Oracle JVM 10.2.0.1.0
   Database Configuration and Upgrade Assistants 10.2.0.1.0
   Oracle interMedia Locator 10.2.0.1.0
   Oracle XML Development Kit 10.2.0.1.0
   Oracle Text 10.2.0.1.0
   Oracle Database Utilities 10.2.0.1.0
   Generic Connectivity Common Files 10.2.0.1.0
   Oracle Advanced Security 10.2.0.1.0
   Enterprise Manager Repository Core 10.2.0.1.0
   PL/SQL 10.2.0.1.0
   Oracle Net 10.2.0.1.0
   Assistant Common Files 10.2.0.1.0
   Enterprise Manager plugin Common Files 10.2.0.1.0 Beta
   Buildtools Common Files 10.2.0.1.0
   Installation Common Files 10.2.0.1.0
   Oracle LDAP administration 10.2.0.1.0
   Oracle Java Client 10.2.0.1.0
   Precompiler Common Files 10.2.0.1.0
   Oracle Recovery Manager 10.2.0.1.0
   SQL*Plus 10.2.0.1.0
   iSQL*Plus 10.2.0.1.0
   Enterprise Manager plugin Common Files 10.2.0.1.0
   HAS Common Files 10.2.0.1.0
   Oracle Clusterware RDBMS Files 10.2.0.1.0
   Oracle Wallet Manager 10.2.0.1.0
   Enterprise Manager Minimal Integration 10.2.0.1.0
   Oracle Database User Interface 2.2.13.0.0
   Secure Socket Layer 10.2.0.1.0
   Oracle ODBC Driver 10.2.0.1.0
   Required Support Files 10.2.0.1.0
   Database SQL Scripts 10.2.0.1.0
   OLAP SQL Scripts 10.2.0.1.0
   PL/SQL Embedded Gateway 10.2.0.1.0
   Oracle Globalization Support 10.2.0.1.0
   Character Set Migration Utility 10.2.0.1.0
   LDAP Required Support Files 10.2.0.1.0
   Oracle Help for the  Web 1.1.10.0.0
   Oracle JDBC Thin Driver for JDK 1.4 10.2.0.1.0
   Oracle JDBC Thin Driver for JDK 1.2 10.2.0.1.0
   Oracle interMedia Client Option 10.2.0.1.0
   Oracle Notification Service 10.1.0.3.0
   Oracle Code Editor 1.2.1.0.0I
   Perl Interpreter 5.8.3.0.2
   JDBC Common Files 10.2.0.1.0
   Oracle Locale Builder 10.2.0.1.0
   Oracle Containers for Java 10.2.0.1.0
   Database Workspace Manager 10.2.0.1.0
   Oracle Core Required Support Files 10.2.0.1.0
   Platform Required Support Files 10.2.0.1.0
   Oracle interMedia Locator RDBMS Files 10.2.0.1.0
   Oracle JDBC/OCI Instant Client 10.2.0.1.0
   Oracle interMedia Annotator 10.2.0.1.0
   SQLJ Runtime 10.2.0.1.0
   Oracle interMedia Java Advanced Imaging 10.2.0.1.0
   Oracle Database 10g interMedia Files 10.2.0.1.0
   Oracle Data Mining RDBMS Files 10.2.0.1.0
   Enterprise Manager Baseline 10.2.0.1.0
   Oracle Help For Java 4.2.6.1.0
   Oracle UIX 2.1.22.0.0
   XML Parser for Java 10.2.0.1.0
   Precompiler Required Support Files 10.2.0.1.0
   XML Parser for Oracle JVM 10.2.0.1.0
   Oracle Message Gateway Common Files 10.2.0.1.0
   Oracle Starter Database 10.2.0.1.0
   Sample Schema Data 10.2.0.1.0
   Parser Generator Required Support Files 10.2.0.1.0
   Agent Required Support Files 10.2.0.1.0
   Oracle RAC Required Support Files-HAS 10.2.0.1.0
   RDBMS Required Support Files 10.2.0.1.0
   RDBMS Required Support Files for Instant Client 10.2.0.1.0
   XDK Required Support Files 10.2.0.1.0
   Oracle OLAP API 10.2.0.1.0
   Oracle OLAP RDBMS Files 10.2.0.1.0
   DBJAVA Required Support Files 10.2.0.1.0
   SQL*Plus Required Support Files 10.2.0.1.0
   Oracle JFC Extended Windowing Toolkit 4.2.33.0.0
   Oracle Ice Browser 5.2.3.6.0
   Oracle Display Fonts 9.0.2.0.0
   Oracle Extended Windowing Toolkit 3.4.38.0.0
   Enterprise Manager Common Files 10.2.0.1.0
   Enterprise Manager Agent DB 10.2.0.1.0
   Oracle Net Required Support Files 10.2.0.1.0
   Enterprise Manager Repository DB 10.2.0.1.0
   SSL Required Support Files for InstantClient 10.2.0.1.0
   regexp 2.1.9.0.0
   Bali Share 1.1.18.0.0
   Oracle Universal Installer 10.2.0.1.0
   Oracle One-Off Patch Installer 10.2.0.1.0
   Installer SDK Component 10.2.0.1.0
   Java Runtime Environment 1.4.2.8.0
   Sun JDK 1.4.2.0.8
   Sun JDK extensions 10.1.2.0.0
-----------------------------------------------------------------------------


Installation in progress (Tue Sep 10 14:46:17 IST 2013)
...............................................................  11% Done.
...............................................................  23% Done.
...............................................................  35% Done.
...............................................................  47% Done.
...........................................                      55% Done.
Install successful

Linking in progress (Tue Sep 10 14:49:44 IST 2013)
.                                                                55% Done.
Link successful

Setup in progress (Tue Sep 10 14:50:33 IST 2013)
....................                                            100% Done.
Setup successful

End of install phases.(Tue Sep 10 14:50:39 IST 2013)
Starting to execute configuration assistants
Configuration assistant "Oracle Net Configuration Assistant" succeeded

[oracle@localhost 10gR2-Linux4,5]$ Configuration assistant "Oracle Database Configuration Assistant" succeeded
Configuration assistant "iSQL*Plus Configuration Assistant" succeeded
WARNING:A new inventory has been created in this session. However, it has not yet been registered as the central inventory of this system.
To register the new inventory please run the script '/oracle/product/10.2.0/oraInventory/orainstRoot.sh' with root privileges.
If you do not register the inventory, you may not be able to update or patch the products you installed.

The following configuration scripts
/oracle/product/10.2.0/db_1/root.sh
need to be executed as root for configuring the system. If you skip the execution of the configuration tools, the configuration will not be complete and the product wont function properly. In order to get the product to function properly, you will be required to execute the scripts and the configuration tools after exiting the OUI.

The installation of Oracle Database 10g was successful.
Please check '/oracle/product/10.2.0/oraInventory/logs/silentInstall2013-09-10_02-45-55PM.log' for more details.

[oracle@localhost 10gR2-Linux4,5]$
[oracle@localhost 10gR2-Linux4,5]$
[oracle@localhost 10gR2-Linux4,5]$
[oracle@localhost 10gR2-Linux4,5]$
[oracle@localhost 10gR2-Linux4,5]$
[oracle@localhost 10gR2-Linux4,5]$
[oracle@localhost 10gR2-Linux4,5]$ cd
[oracle@localhost ~]$
[oracle@localhost ~]$
[oracle@localhost ~]$
[oracle@localhost ~]$ sqlplus

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Sep 10 14:58:06 2013

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

Enter user-name: /as sysdba

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL>
SQL>
SQL> select name from v$database;

NAME
---------
ORCL

SQL>
SQL>
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@localhost ~]$
[oracle@localhost ~]$
[oracle@localhost ~]$
[oracle@localhost ~]$

Monday, September 2, 2013

HOW TO CHANGE CHARACTER SET IN ORACLE

Install CSSCAN


login with SYS user

@?/rdbms/admin/csminst.sql

###############

csscan \"sys as sysdba\" full=y

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production

With the Partitioning, OLAP and Data Mining options


Current database character set is AL32UTF8.


Enter new database character set name: > WE8ISO8859P1


Enter array fetch buffer size: 1024000 >


Enter number of scan processes to utilize(1..32): 1 > 4


Enumerating tables to scan...


The output goes into 3 files: scan.err, scan.out, scan.txt

Detailed description can be found in Oracle Support document "Csscan output explained [ID 444701.1]".


3. Backup database if it has not been done yet.


4. Dealing with Truncation and Lossy data

Check file scan.txt

With some lossy data, I had the following summary:

[Scan Summary]

All character type data in the data dictionary are convertible to the new character set

Some character type application data are not convertible to the new character set


There was no Truncation data in this DB.

Lossy data were found in one table (TOAD_PLAN_TABLE) and I’ve just dropped it.

More info about dealing with Lossy and Transaction data can be found in Oracle document " Changing the NLS_CHARACTERSET to AL32UTF8 / UTF8 (Unicode) [ID 260192.1]"


5. Dealing with Convertible data

"Convertible" Data Dictionary CLOB data is handled by CSALTER. No action required.

"Convertible" Application Data has to be exported and deleted!

When there are application Convertible data without Truncation/Lossy data, scan summary in scan.txt looks like:

[Scan Summary]

All character type data in the data dictionary are convertible to the new character set

All character type application data are convertible to the new character set


In this case there were two application tables with convertible data.

[Application Data Conversion Summary]

Datatype         Changeless  Convertible   Truncation  Lossy

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

VARCHAR2     15,045,735,123          280            0      0

CHAR                      0            0            0      0

LONG                      0            0            0      0

CLOB                      0            0            0      0

VARRAY                    0            0            0      0

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


[Distribution of Convertible, Truncated and Lossy Data by Table]

USER.TABLE                Convertible  Truncation  Lossy

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

EDWSTG_HM.JOBS                     21           0      0

EDWSTG_HM.TRANSACTIONS            259           0      0


Export and truncate

expdp \"/ as sysdba\" DUMPFILE=t01_%u.dmp LOGFILE=t01.log tables=EDWSTG_HM.JOBS,EDWSTG_HM.TRANSACTIONS parallel=4


SQL> truncate table EDWSTG_HM.JOBS;

SQL> truncate table EDWSTG_HM.TRANSACTIONS;


6. Run CSSCAN again.

csscan \"sys as sysdba\" full=y


To run CSALTER the following output of CSSCAN (scan.txt) is required:


[Scan Summary]

All character type data in the data dictionary are convertible to the new character set

All character type application data remain the same in the new character set


[Data Dictionary Conversion Summary]



The data dictionary can be safely migrated using the CSALTER script


7. Conversion

Shutdown listener and make sure nothing else connects to the database.


sqlplus / as sysdba

show parameter job_queue_processes

show parameter aq_tm_processes

-- assuming spfile is in use

alter system set job_queue_processes=0;

alter system set aq_tm_processes=0;

shutdown immediate;


startup restrict

spool convert.log

@?/rdbms/admin/csalter.plb


Restart the database and listener.


8. Post conversion steps

Restore altered parameters

alter system set job_queue_processes=10;

alter system set aq_tm_processes=1;



###############







-------------------------Change Oracle DB Character Set---------------------------------------------





If you want to change from WE8MSWIN1252 to AL32UTF8. Check the NLS parameters first.



SQL> SELECT PARAMETER, VALUE FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER IN ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET');

---------------------------------------Changing Commands------------------------------------------------

The syntax of the ALTER DATABASE CHARACTER SET statement is as follows:



SQL> ALTER DATABASE [db_name] CHARACTER SET new_character_set;



(db_name is an optional)



For Example :



SQL> ALTER DATABASE CHARACTER SET AL32UTF8;



--------------------------------Steps to change the database character set------------------------------------------

To change the database character set, perform the following steps:



1. Shut down the database, using either a SHUTDOWN IMMEDIATE or a SHUTDOWN NORMAL statement.



2. Do a full backup of the database because the ALTER DATABASE CHARACTER SET statement cannot be rolled back.



3. Startup Oracle database



SQL> startup mount;

SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;

SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;

SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0;

SQL> ALTER DATABASE OPEN;

SQL> ALTER DATABASE CHARACTER SET AL32UTF8;

If you get the error ORA-12712, please update the following table.



"ORA-12712: new character set must be a superset of old character set"



SQL> update sys.props$ set VALUE$='AL32UTF8' where NAME='NLS_CHARACTERSET';

SQL> commit;

If you get the error ORA-12721, please login as DBA user.



"ORA-12721: operation cannot execute when other sessions are active"



4. shutdown immediate;  or shutdown normal;



5. startup oracle database



SQL> startup mount;

SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;

SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;

SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0;

SQL> ALTER DATABASE OPEN;

SQL> ALTER DATABASE CHARACTER SET AL32UTF8;



SQL> shutdown immediate;

SQL> startup;



--------------------------------------Check the NLS parameters-------------------------------------------

SQL> SELECT PARAMETER, VALUE FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER IN ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET');