Wednesday, June 21, 2017

HOW TO CHANGE NO ARCHIVE LOG MODE TO ARCHIVE LOG IN RAC ENVIRONMENT

HOW TO CHANGE  NO ARCHIVE LOG MODE TO ARCHIVE LOG IN RAC

Enable Archivelog ::

1) verify the archive log mode in any one of the node

To check the archive log list you need to run the commnd " Archive log list"

SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     86
Current log sequence           88

SQL> select name, log_mode from v$database;

NAME LOG_MODE
--------- ------------
ocrac NOARCHIVELOG

2) You need to disable the cluster instance parameter by setting cluster_database to FALSE from the current instance.
Pleae follow the below steps.

sqlplus "/ as sysdba"
SQL> alter system set cluster_database=false scope=spfile sid='ocrac';

3) Now you have to shutdown all instances accessing the clustered database

  srvctl stop database -d ocrac

4) Using the local instance, MOUNT the database:

sqlplus "/ as sysdba"
SQL> startup mount

5) Enable archiving

SQL> alter database archivelog;

Now you have successfully enable the archivelog mode.

6) You have to re-enable the instance parameter cluster_database to TRUE from the current instance by using the following command.

SQL> alter system set cluster_database=true scope=spfile sid='ocrac';

7) You have to bounce the local instance.

SQL> shutdown immediate

8) Bring all instance back up using srvctl.

srvctl start database -d ocrac

9) Login to the local instance and verify Archive Log Mode is enabled

sqlplus "/ as sysdba"
SQL> archive log list
Database log mode            Archive Mode
Automatic archival             Enabled
Archive destination           /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch
Oldest online log sequence     86
Next log sequence to archive  88
Current log sequence               89

10) After enabling Archive Log Mode, each instance in the RAC configuration can automatically archive redologs.

Disable Archivelog ::

1) set oracle_sid=ocrac
SQL> alter system set cluster_database=false scope=spfile sid='ocrac';
System altered.

2) /u01/app/grid/bin> srvctl stop database -d ocrac -o immediate

3) SQL> startup mount
Total System Global Area 2471931904 bytes
Fixed Size            2255752 bytes
Variable Size          671089784 bytes
Database Buffers     1778384896 bytes
Redo Buffers           20201472 bytes
Database mounted.

SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 8
Next log sequence to archive 9
Current log sequence 9

SQL> alter database noarchivelog;
Database altered.
SQL> alter system set cluster_database=true scope=spfile sid='ocrac';
System altered.

SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.

4) /u01/app/grid/bin>>srvctl start database -d ocrac

5) export ORACLE_SID=ocrac

oracle@ocluster01:~| /home/oracle >sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 21 19:55:19 2017

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL>

SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 18
Current log sequence 19
SQL>
 

DDL, DML, DCL and TCL Statements in SQL with Examples

DDL, DML, DCL and TCL Statements in SQL

SQL language is divided into four types of primary language statements.
They are DML, DDL, DCL and TCL.

1. DML (Data Manipulation Language)
2. DDL (Data Definition Language)
3. DCL (Data Control Language)
4. TCL (Transaction Control Language)

Using these statements, we can define the structure of a database by creating and altering database objects.
These are basic operations we perform on data such as selecting a few records from a table, inserting new records, deleting unnecessary records, and updating/modifying existing records.
We also can control which user can read/write data or manage transactions to create a single unit of work.

DML statements include the following:

SELECT – select records from a table
INSERT – insert new records
UPDATE – update/Modify existing records
DELETE – delete existing records

DDL (Data Definition Language)

DDL statements are used to alter/modify a database or table structure and schema.

statements are used to define the database structure or schema.

CREATE – create a new Table, database, schema
ALTER – alter existing table, column description
DROP – delete existing objects from database
TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed
COMMENT - add comments to the data dictionary
RENAME - rename an object

DCL (Data Control Language)

DCL statements control the level of access that users have on database objects.

GRANT – allows users to read/write on certain database objects
REVOKE – keeps users from read/write permission on database objects
TCL (Transaction Control Language)

TCL statements allow you to control and manage transactions to maintain the integrity of data within SQL statements.

BEGIN Transaction – opens a transaction
COMMIT Transaction – commits a transaction
ROLLBACK Transaction – ROLLBACK a transaction in case of any error