Tuesday, November 27, 2018

How to change the character set of the database.


How to change the character set of the database.

1. Check the current database character set.
1
2
3
select value
from nls_database_parameters
where parameter='NLS_CHARACTERSET';
2. Sometimes it could be not enough – here is the query to check ALL database character sets.
1
2
3
4
5
6
7
select distinct(nls_charset_name(charsetid)) CHARACTERSET,
decode(type#, 1, decode(charsetform, 1, 'VARCHAR2', 2, 'NVARCHAR2','UNKOWN'),
9, decode(charsetform, 1, 'VARCHAR', 2, 'NCHAR VARYING', 'UNKOWN'),
96, decode(charsetform, 1, 'CHAR', 2, 'NCHAR', 'UNKOWN'),
112, decode(charsetform, 1, 'CLOB', 2, 'NCLOB', 'UNKOWN')) TYPES_USED_IN
from sys.col$
where charsetform in (1,2)
and type# in (1, 9, 96, 112);
3. Log into the database and do a clean shutdown of the database.
1
SHUTDOWN IMMEDIATE;
If for whatever reason, the database does not get shut down cleanly (via a shutdown immediate command), start it back up in restrict mode and shut it down again.
Note --Do a full backup of the database because the ALTER DATABASE CHARACTER SET statement cannot be rolled back.
4. Mount the database.
1
STARTUP MOUNT;
5. Restrict logon to the database, disable job processes and queue processes.
1
2
3
ALTER SYSTEM ENABLE RESTRICTED SESSION;
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
ALTER SYSTEM SET AQ_TM_PROCESSES=0;
6. Open the database.
1
ALTER DATABASE OPEN;
7. Change the character set (instead of &CHARSET use the proper character set, e.g. ‘EE8MSWIN1250’).
1
ALTER DATABASE CHARACTER SET INTERNAL_USE &CHARSET;
8. You can also change the national character set (instead of &NCHARSET use the proper character set, e.g. ‘AL16UTF16’)
1
ALTER DATABASE NATIONAL CHARACTER SET INTERNAL_USE &NCHARSET;
9. Make a clean shutdown of the database.
1
SHUTDOWN IMMEDIATE;
10. Start it up.
1
STARTUP;

Caution! Changing the character set can sometimes cause data loss or data corruption.
I strongly encourage to make a full backup of the database, before attempting to migrate the data to a new character set.

Sunday, November 25, 2018

Common Oracle error codes


Common Oracle error codes

ORA-00001- Unique constraint violated. (Invalid data has been rejected)
 
ORA-00600- Internal error (contact support)
 
ORA-03113 End-of-file on communication channel (Network connection lost)
 
ORA-03114 Not connected to ORACLE 
 
ORA-00942 Table or view does not exist 
 
ORA-01017 Invalid Username/Password
 
ORA-01031 Insufficient privileges 
 
ORA-01034 Oracle not available (the database is down)
 
ORA-01403 No data found
 
ORA-01555 Snapshot too old (Rollback has been overwritten)
 
ORA-12154 TNS:could not resolve service name 
 
ORA-12203 TNS:unable to connect to destination
 
ORA-12500 TNS:listener failed to start a dedicated server 
Process
 
ORA-12545 TNS:name lookup failure
 
ORA-12560 TNS:protocol adapter error
 
ORA-02330 Package error raised with 
DBMS_SYS_ERROR.RAISE_SYSTEM_ERROR
 
Other error prefix codes
 
PLS-????? PL/SQL Error
IMP-????? Import error
EXP-????? Export error
MOD-????? SQL Module error
FRM-????? Oracle Forms error
SQL-Loader-??? SQL Loader error


Tuesday, November 20, 2018

Difference Between oracle 10g,12C & 18C

Database Compersion

Oracle10g
Oracle 12C
Oracle18C
Data Guard improvements
DataGuard enhancements
Active DataGuard added
 Realtime apply and log compressions
Detection of gasps and automatic resolution
Standby Database can now be queried where redo apply is active


Backup and Recovery
Backup and Recovery
Improved Manageability
.    Data Pump Added
 Block level recovery
 ASM Cluster FileSystem (ACFS) Introduced
 Improved reporting and automation
 Virtual Columns added
Security
Security
Security
Password is not case sensitive 
Password case sensitive
Password  complexity   

Improved reporting and automation


Oracle 12C supports In-memory aggregation, which improves of queries and  Reduce the CPU Usage
In-Memory in Oracle Database 18c also allows you to place data from external tables in the column store. Also It can now scan compression units in-parallel to double the speed of data read
single index
Multiple indexes
Virtual Indexes
Table space Rename
Move Datafile

Need Database Shutdown to change archive log mode
No need to shutdown database for changing archive log mode.


Oracle 12c introduced a lot of online partition features
Oracle 18c, we can MERGE PARTITIONS online and maintain the indexes.
Not Possible
 -
Oracle 18c users to create temporary database objects that are automatically dropped at the end of a transaction or a session.

Optimized more database .We can add other application also there which will save licence cost of db server and system cost.
 Optimized more database .We can add other application also there which will save licence cost of db server and system cost



Monday, November 19, 2018

What is meaning of i, g and c in Oracle Database Version


What is meaning of i, g and c in Oracle Database Version



Oracle DBAs and Developers .. ever wondered the meaning of i, g and c in Oracle Database Releases version .So I try to explain you in simple language.

Oracle 8i, 9i

The ‘i’ in oracle 8i and 9i stands for INTERNET.Starting in 1999 with Version 8i, Oracle added the "i" to the version name to reflect support for the Internet with its built-in Java Virtual Machine (JVM). Oracle 9i added more support for XML in 2001.

 Oracle 10g, 11g

10g and 11g stands for GRID.Starting in 2003 with version 10g and 11g, G signifies “Grid Computing” with the release of Oracle10g in 2003. Oracle 10g was introduced with emphasis on the “g” for grid computing, which enables clusters of low-cost, industry standard servers to be treated as a single unit. 

 Oracle 12c

In the Oracle Database 12c the "c" stands for "Cloud”.In addition to many new features, this new version of the Oracle Database implements a multitenant architecture, which enables the creation of pluggable databases (PDBs) in a multitenant container database (CDB)
So I hope you all now know what is the meaning of “i”,”c” and “g” in Oracle Database.

Thursday, November 15, 2018

Audit - Enabling or Disabling Audit Trail




The Oracle Server provides several auditing options.
The following three types of audits are provide by Oracle
 1. Session audits (LOGON,LOGOFF etc)
 2. Database action and object audits and
 3. DDL(CREATE, ALTER & DROP of objects)


The three main views to see the AUDIT Information are:

·         DBA_AUDIT_TRAIL – Standard auditing only (from AUD$).
·         DBA_FGA_AUDIT_TRAIL – Fine-grained auditing only (from FGA_LOG$) [For 10g].
·         DBA_COMMON_AUDIT_TRAIL – Both standard and fine-grained auditing   [For 10g].
To enable database auditing, you must provide a value for the AUDIT_TRAIL parameter.


Note - Auditing is disabled by default, but can enabled by setting the AUDIT_TRAIL static parameter, which has the following allowed values.

SQL> SHOW PARAMETER AUDIT

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
audit_file_dest                      string      C:\ORACLE\PRODUCT\10.2.0\ADMIN
                                                 \ORCL\ADUMP
audit_sys_operations                 boolean     FALSE
audit_trail                          string      DB

The initialization parameters of audit facility of Oracle

AUDIT_TRAIL = { none | os | db | db,extended | xml | xml,extended }
DB              Auditing is enabled. Audit records will be written to the
                SYS.AUD$ table.
OS              Auditing is enabled. Audit records will be written to an
                audit trail in the operating system.
db,extended     As db, but the SQL_BIND and SQL_TEXT columns are also populated.
NONE            Auditing is disabled (default).
xml-            Auditing is enabled, with all audit records stored
                as XML format OS files.
xml,extended    As xml, but the SQL_BIND and SQL_TEXT columns are also populated.
TRUE            This value is supported for backward-compatibility
                with versions of Oracle;it is equivalent to the DB value.
FALSE           This value is supported for backward-compatibility
                with versions of Oracle;it is equivalent to the NONE value.
In Oracle 10g Release 1, db_extended was used in place of db,extended. The XML options are new to Oracle 10g Release 2

Set audit_trail to DB in pfile (audit_trail = DB) .

Enable auditing and direct audit records to the database audit trail
SQL> ALTER SYSTEM SET audit_trail=db SCOPE=SPFILE;

System altered.

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

Total System Global Area  612368384 bytes
Fixed Size                  1250452 bytes
Variable Size             230689644 bytes
Database Buffers          377487360 bytes
Redo Buffers                2940928 bytes
Database mounted.
The command to begin auditing connects (login) attempts is:
AUDIT SESSION;
AUDIT SESSION WHENEVER SUCCESSFUL;
AUDIT SESSION WHENEVER NOT SUCCESSFUL;
To view the report of Audit session run the following query.
SQL Code: 
SELECT os_username,
     username,
     terminal,
     returncode,
     TO_CHAR(timestamp,   'DD-MON-YYYY HH24:MI:SS') LOGON_TIME,
     TO_CHAR(logoff_time, 'DD-MON-YYYY HH24:MI:SS') LOGOFF_TIME
FROM dba_audit_session;


Disable Session Audit
SQL> NOAUDIT;
SQL> NOAUDIT session;
SQL> NOAUDIT session BY scott, hr;
SQL> NOAUDIT DELETE ON emp;
SQL> NOAUDIT SELECT TABLE, INSERT TABLE, DELETE TABLE, EXECUTE PROCEDURE;
SQL> NOAUDIT ALL;
SQL> NOAUDIT ALL PRIVILEGES;
SQL> NOAUDIT ALL ON DEFAULT;


How to create user in MY SQL

Create  a new MySQL user Account mysql > CREATE USER ' newuser '@'localhost' IDENTIFIED BY ' password '...