upgrade oracle from10g to 11g prerequest and postrequest

Oracle 10g database is upgrade to oracle 11g database.This upgrade support from 10.2.0.4.0 to 11.1.0.6.0 version only.
Step -1
Pre Request
1. Check the database version.
SQL> select * from v$version;
BANNER
—————————————————————-
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – Prod
PL/SQL Release 10.2.0.4.0 – Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 – Production
NLSRTL Version 10.2.0.4.0 – Production

2. Check the packages validity.
SQL> select comp_name, version, status from sys.dba_registry;
COMP_NAME VERSION STATUS
———————————————– ———— ——
Oracle Database Catalog Views 10.2.0.4.0 VALID
Oracle Database Packages and Types 10.2.0.4.0 VALID
2 rows selected.
3. Check whether objects are valid
SQL> select object_name,status from dba_objects
where status=’INVALID’;
no rows selected.


4. Check whether any datafile is in backup mode
SQL> select * from v$backup where status=’ACTIVE’;
FILE# STATUS CHANGE# TIME
——— —————- ——————
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 NOT ACTIVE 0
5.check whether any datafiles is in recovery state
SQL> select * from v$recover_file;
no rows selected.
5. Stop the listener
lsnrctl> stop listener
Step -2
1)create 11g directory and new 11g bash profile and set it.
mkdir -p /u01/app/oracle/product/11.1.0/db_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=ten.localdomain; export ORACLE_HOSTNAME
ORACLE_UNQNAME=DB11G; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1; export ORACLE_HOME
ORACLE_SID=DB11G; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

2)no need to shutdown 10.2.0.4.0 db

3)install 11gr1 using other terminal
database]$./runInstaller

4) go to 10.2.0.4.0 terminal
[oracle@teng ~]$ . .10g_profile
[oracle@teng ~]$ export ORACLE_SID=kfc
[oracle@teng ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 – Production on Thu Aug 11 10:52:45 2016

4.1)This utlu111i.sql script check the database and list requirements to upgrade.
SQL> spool db10g
SQL> @/u01/app/oracle/product/11.1.0/db_1/rdbms/admin/utlu111i.sql
SQL> spool off

4.2) create pfile in $ORACLE_HOME/dbs location
SQL>create pfile=’/u01/app/oracle/product/11.1.0/db_1/dbs/initkfc.ora’ from spfile;

4.3) Edit the parameter in pfile with upgrade requirements
     change this background_dump_dest=’/home/oracle/kfc/admin/bdump’ to
                diagnostic_dest=’/home/oracle/kfc/admin/diag/’
                 remove cdump and udump

5. Shut 10.2.0.4.0  the database and services (stop css if using asm) for Upgrade
SQL> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.
TO UPGRADE
1. run a new 11g bash profile and set it.
. .bash_profile

2. Start the database with Upgrade option (if using asm start asm instance and css)
sqlplus sys/*** as sysdba
SQL*Plus: Release 11.1.0.6.0 – Production on Tue Apr 27 09:50:25 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup upgrade;
ORACLE instance started.
Total System Global Area 534462464 bytes
Fixed Size 2146112 bytes
Variable Size 150995136 bytes
Database Buffers 377487360 bytes
Redo Buffers 3833856 bytes
Database mounted.
Database opened.

3. Run this script for database upgradataion
SQL> @?/rdbms/admin/catupgrd.sql
POST UPGRADE REQUEST
1. Check status of database components
SQL> select comp_name,version, status from dba_registry
COMP_NAME VERSION STATUS
—————————————- —————————— —————
Oracle Enterprise Manager 11.1.0.6.0 VALID
OLAP Catalog 11.1.0.6.0 VALID

2. Check for invalid objects
SQL> select count(*) from dba_objects where status like ‘INVALID’;
COUNT(*)
———-
0

3.Run this script to verify the database upgrade
@?/rdbms/admin/utlu111s.sql


4. Restart the database normally and start the listener.
SQL> shut immediate
lsnrctl> start listener
SQL> startup

oracle upgrade 10g to 11g

Oracle 10g database is upgrade to oracle 11g database.This upgrade support from 10.2.0.4.0 to 11.1.0.6.0 version only.
Step -1
Pre Request:-
1. Check the database version.
SQL> select * from v$version;
BANNER
—————————————————————-
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – Prod
PL/SQL Release 10.2.0.4.0 – Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 – Production
NLSRTL Version 10.2.0.4.0 – Production

2. Check the packages validity.
SQL> select comp_name, version, status from sys.dba_registry;
COMP_NAME VERSION STATUS
———————————————– ———— ——
Oracle Database Catalog Views 10.2.0.4.0 VALID
Oracle Database Packages and Types 10.2.0.4.0 VALID
2 rows selected.
3. Check whether objects are valid
SQL> select object_name,status from dba_objects
where status=’INVALID’;
no rows selected.


4. Check whether any datafile is in backup mode
SQL> select * from v$backup where status=’ACTIVE’;
FILE# STATUS CHANGE# TIME
——— —————- ——————
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 NOT ACTIVE 0
5.check whether any datafiles is in recovery state
SQL> select * from v$recover_file;
no rows selected.
5. Stop the listener
lsnrctl> stop listener
Step -2
1)create 11g directory and new 11g bash profile and set it.
mkdir -p /u01/app/oracle/product/11.1.0/db_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=ten.localdomain; export ORACLE_HOSTNAME
ORACLE_UNQNAME=DB11G; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1; export ORACLE_HOME
ORACLE_SID=DB11G; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

2)no need to shutdown 10.2.0.4.0 db

3)install 11gr1 using other terminal
database]$./runInstaller

4) go to 10.2.0.4.0 terminal
[oracle@teng ~]$ . .10g_profile
[oracle@teng ~]$ export ORACLE_SID=kfc
[oracle@teng ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 – Production on Thu Aug 11 10:52:45 2016

4.1)This utlu111i.sql script check the database and list requirements to upgrade.
SQL> spool db10g
SQL> @/u01/app/oracle/product/11.1.0/db_1/rdbms/admin/utlu111i.sql
SQL> spool off

4.2) create pfile in $ORACLE_HOME/dbs location
SQL>create pfile=’/u01/app/oracle/product/11.1.0/db_1/dbs/initkfc.ora’ from spfile;

4.3) Edit the parameter in pfile with upgrade requirements
     change this background_dump_dest=’/home/oracle/kfc/admin/bdump’ to
                diagnostic_dest=’/home/oracle/kfc/admin/diag/’
                 remove cdump and udump

5. Shut 10.2.0.4.0  the database and services (stop css if using asm) for Upgrade
SQL> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.
TO UPGRADE
1. run a new 11g bash profile and set it.
. .bash_profile

2. Start the database with Upgrade option (if using asm start asm instance and css)
sqlplus sys/*** as sysdba
SQL*Plus: Release 11.1.0.6.0 – Production on Tue Apr 27 09:50:25 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup upgrade;
ORACLE instance started.
Total System Global Area 534462464 bytes
Fixed Size 2146112 bytes
Variable Size 150995136 bytes
Database Buffers 377487360 bytes
Redo Buffers 3833856 bytes
Database mounted.
Database opened.

3. Run this script for database upgradataion
SQL> @?/rdbms/admin/catupgrd.sql
POST UPGRADE REQUEST
1. Check status of database components
SQL> select comp_name,version, status from dba_registry
COMP_NAME VERSION STATUS
—————————————- —————————— —————
Oracle Enterprise Manager 11.1.0.6.0 VALID
OLAP Catalog 11.1.0.6.0 VALID

2. Check for invalid objects
SQL> select count(*) from dba_objects where status like ‘INVALID’;
COUNT(*)
———-
0

3.Run this script to verify the database upgrade
@?/rdbms/admin/utlu111s.sql


4. Restart the database normally and start the listener.
SQL> shut immediate
lsnrctl> start listener
SQL> startup

oracle dba ——CREATE USER Database User Management

CREATE USER user
   IDENTIFIED { BY password
              | EXTERNALLY [ AS ‘certificate_DN’ ]
              | GLOBALLY [ AS ‘[ directory_DN ]’ ]
              }
   [ DEFAULT TABLESPACE tablespace
   | TEMPORARY TABLESPACE
        { tablespace | tablespace_group_name }
   | { QUOTA { size_clause | UNLIMITED } ON tablespace }…
EDO   | PROFILE profile
   | PASSWORD EXPIRE
   | ACCOUNT { LOCK | UNLOCK }
     [ DEFAULT TABLESPACE tablespace
     | TEMPORARY TABLESPACE
          { tablespace | tablespace_group_name }
     | { QUOTA { size_clause | UNLIMITED } ON tablespace }…
     | PROFILE profile
     | PASSWORD EXPIRE
     | ACCOUNT { LOCK | UNLOCK }
     ]…
  ] ;

CREATE AND DROP USER:
create user shaan identified by moon
default tablespace rtbs
temporary tablespace temp
quota 30m on rtbs;
Above command creates a user shaan with password moon. Consider the tablespace
you have in which shaan will store his data is “RTBS”. The tablespace used for
storing temporary segments will be “TEMP” and the amount of space which the user
shaan can use on “RTBS” tablespace is 30M.
SQL> DROP USER SHAAN CASCADE;

ALTERING/UNLOCKING ACCOUNT:
SQL> alter user shaan identified by moon account unlock;
The above command alters or unlocks the “SHAAN” user with password “moon”.
SQL> select username, account_status, default_tablespace,
temporary_tablespace, profile from dba_users
where username = ‘HRMS’;
USERNAME ACCOUNT_STATUS DEFAULT_TABLESPACE TEMPORARY_TABLESPACE PROFILE
—— ————– —————— ——————– ———
HRMS      OPEN           MUJ_HRMS_DBF      TEMP                 DEFAULT
The above query shows the account information related to “HRMS”.

ALTERING TABLEPSACE QUOTA:
SQL> select * from dba_ts_quotas where username = ‘HRMS’;
TABLESPACE_NAME USERNAME BYTES MAX_BYTES BLOCKS MAX_BLOCKS
————— ——– —– ——— —— ———-
MUJ_HRMS_DBF    HRMS     198901760 -1    24280  -1
SQL> alter user shaan quota 40m on RTBS;‎

GRANTING AND REVOKING PRIVILEGES:
SQL> GRANT create table to SHAAN;‎
SQL> GRANT create session to SHAAN;
SQL> GRANT create any table, create tablespace to SHAAN;
SQL> REVOKE create any table from SHAAN;
SQL> REVOKE create tablespace from SHAAN;
SQL> GRANT select, insert, update, delete on HRSM.PAY_PAYMENT_MASTER to HRMS;
SQL> REVOKE update,delete on HRMS.PAY_PAYMENT_MASTER from HRMS;

ROLES:
SQL>create role MY_ROLE;
SQL> GRANT create any table, alter any table, drop any table, select any table, update any table,
delete any table to MY_ROLE;
SQL> GRANT create any index, alter any index, drop any index to MY_ROLE
SQL> GRANT alter session, restricted session to MY_ROLE;
SQL> GRANT create tablespace, alter tablespace, drop tablespace, unlimited tablespace
to MY_ROLE;
SQL> GRANT select, insert, update, delete on HRMS.PAY_PAYMENT_MASTER to MY_ROLE;
SQL> GRANT MY_ROLE to SHAAN;
SQL> select * from dba_sys_privs where grantee = ‘SHAAN’;
GRANTEE                        PRIVILEGE            ADM
———————-         ——————– —
SHAAN                          CREATE TABLE         NO
SHAAN                          CREATE SESSION       NO
SQL> select * from dba_sys_privs where grantee = ‘MY_ROLE’‎
GRANTEE                        PRIVILEGE                   ADM
———————-         ————————— —
MY_ROLE                        DELETE ANY TABLE            NO
MY_ROLE                        CREATE ANY TABLE            NO
MY_ROLE                        DROP TABLESPACE             NO
MY_ROLE                        ALTER TABLESPACE            NO
MY_ROLE                        ALTER ANY INDEX             NO
MY_ROLE                        DROP ANY TABLE              NO
MY_ROLE                        DROP ANY INDEX              NO
MY_ROLE                        UPDATE ANY TABLE            NO
MY_ROLE                        ALTER SESSION               NO
MY_ROLE                        SELECT ANY TABLE            NO
MY_ROLE                        RESTRICTED SESSION          NO
MY_ROLE                        CREATE ANY INDEX            NO
MY_ROLE                        ALTER ANY TABLE             NO
MY_ROLE                        UNLIMITED TABLESPACE        NO
MY_ROLE                        CREATE TABLESPACE           NO
SQL> select grantee, owner, table_name, grantor, privilege from dba_tab_privs
‎where grantee = ‘SHAAN’;‎
GRANTEE  OWNER  TABLE_NAME   GRANTOR    PRIVILEGE
——– —— ———— ———  ———
HRMS     HRMS  PAY_PAYMENT_MASTER HRMS  SELECT
HRMS     HRMS  PAY_PAYMENT_MASTER HRMS  INSERT
SQL> select grantee, owner, table_name, grantor, privilege from dba_tab_privs
where grantee = ‘MY_ROLE’‎;
GRANTEE  OWNER  TABLE_NAME   GRANTOR    PRIVILEGE
——– —— ———— ———  ———
MY_ROLE  HRMS  PAY_PAYMENT_MASTER HRMS  UPDATE
MY_ROLE  HRMS  PAY_PAYMENT_MASTER HRMS  SELECT
MY_ROLE  HRMS  PAY_PAYMENT_MASTER HRMS  INSERT
MY_ROLE  HRMS  PAY_PAYMENT_MASTER HRMS  DELETE
SQL> select * from dba_roles where role = ‘MY_ROLE’;‎
ROLE                  PASSWORD AUTHENTICAT
——————— ——– ———–
MY_ROLE               NO       NONE
SQL> select * from dba_role_privs where grantee = ‘SHAAN’;‎
GRANTEE                        GRANTED_ROLE    ADM DEF
————————       ————— — —
SHAAN                          MY_ROLE         NO  YES
SQL> select * from role_sys_privs where role = ‘MY_ROLE’;‎
ROLE                  PRIVILEGE                       ADM
——————— ——————————- —
MY_ROLE               DROP TABLESPACE                 NO
MY_ROLE               CREATE ANY TABLE                NO
MY_ROLE               DELETE ANY TABLE                NO
MY_ROLE               ALTER TABLESPACE                NO
MY_ROLE               DROP ANY TABLE                  NO
MY_ROLE               ALTER ANY INDEX                 NO
MY_ROLE               UPDATE ANY TABLE                NO
MY_ROLE               DROP ANY INDEX                  NO
MY_ROLE               ALTER SESSION                   NO
MY_ROLE               RESTRICTED SESSION              NO
MY_ROLE               SELECT ANY TABLE                NO
MY_ROLE               CREATE TABLESPACE               NO
MY_ROLE               UNLIMITED TABLESPACE            NO
MY_ROLE               ALTER ANY TABLE                 NO
MY_ROLE               CREATE ANY INDEX                NO
SQL> select * from role_tab_privs where role = ‘MY_ROLE’;‎Code:
ROLE     OWNER   TABLE_NAME   COLUMN_NAME   PRIVILEGE   GRA
——– ——- ———— ————- ———– —
MY_ROLE  HRMS   PAY_PAYMENT_MASTER          DELETE       NO
MY_ROLE  HRMS   PAY_PAYMENT_MASTER          UPDATE       NO
MY_ROLE  HRMS   PAY_PAYMENT_MASTER          SELECT       NO
MY_ROLE  HRMS   PAY_PAYMENT_MASTER          INSERT       NO
SQL> revoke MY_ROLE from SHAAN;

PROFILES:
SQL> create profile DEVELOPER limit
failed_login_attempts 3
password_lock_time unlimited
password_life_time 30
password_reuse_time 30
password_grace_time 5
idle_time 30;

SQL> alter user SHAAN profile developer;
SQL> select * from dba_profiles where profile = ‘DEVELOPER’;
PROFILE     RESOURCE_NAME                    RESOURCE LIMIT
———– ————–                   ——– —–
DEVELOPER   COMPOSITE_LIMIT                  KERNEL   DEFAULT
DEVELOPER   SESSIONS_PER_USER                KERNEL   DEFAULT
DEVELOPER   CPU_PER_SESSION                  KERNEL   DEFAULT
DEVELOPER   CPU_PER_CALL                     KERNEL   DEFAULT
DEVELOPER   LOGICAL_READS_PER_SESSION        KERNEL   DEFAULT
DEVELOPER   LOGICAL_READS_PER_CALL           KERNEL   DEFAULT
DEVELOPER   IDLE_TIME                        KERNEL   30
DEVELOPER   CONNECT_TIME                     KERNEL   DEFAULT
DEVELOPER   PRIVATE_SGA                      KERNEL   DEFAULT
DEVELOPER   FAILED_LOGIN_ATTEMPTS            PASSWORD 3
DEVELOPER   PASSWORD_LIFE_TIME               PASSWORD 30
DEVELOPER   PASSWORD_REUSE_TIME              PASSWORD 30
DEVELOPER   PASSWORD_REUSE_MAX               PASSWORD DEFAULT
DEVELOPER   PASSWORD_VERIFY_FUNCTION         PASSWORD DEFAULT
DEVELOPER   PASSWORD_LOCK_TIME               PASSWORD UNLIMITED
DEVELOPER   PASSWORD_GRACE_TIME              PASSWORD 5
SQL> drop profile developer cascade;

Oracle Core DBA Interview questions – Backup and Recovery –8

1.       Which types of backups you can take in Oracle?

2.       A database is running in NOARCHIVELOG mode then which type of backups you can take?

3.       Can you take partial backups if the Database is running in NOARCHIVELOG mode?

4.       Can you take Online Backups if the the database is running in NOARCHIVELOG mode?

5.       How do you bring the database in ARCHIVELOG mode from NOARCHIVELOG mode?

6.       You cannot shutdown the database for even some minutes, then in which mode you should run
the database?

7.       Where should you place Archive logfiles, in the same disk where DB is or another disk?

8.       Can you take online backup of a Control file if yes, how?

9.       What is a Logical Backup?

10.   Should you take the backup of Logfiles if the database is running in ARCHIVELOG mode?

11.   Why do you take tablespaces in Backup mode?

12.   What is the advantage of RMAN utility?

13.   How RMAN improves backup time?

14.   Can you take Offline backups using RMAN?

15.   How do you see information about backups in RMAN?

16.   What is a Recovery Catalog?

17.   Should you place Recovery Catalog in the Same DB?

18.   Can you use RMAN without Recovery catalog?

19.   Can you take Image Backups using RMAN?

20.   Can you use Backupsets created by RMAN with any other utility?

21.   Where RMAN keeps information of backups if you are using RMAN without Catalog?

22.   You have taken a manual backup of a datafile using o/s. How RMAN will know about it?

23.   You want to retain only last 3 backups of datafiles. How do you go for it in RMAN?

24.   Which is more efficient Incremental Backups using RMAN or Incremental Export?

25.   Can you start and shutdown DB using RMAN?

26.   How do you recover from the loss of datafile if the DB is running in NOARCHIVELOG mode?

27.   You loss one datafile and it does not contain important objects. The important objects are there in other datafiles which are intact. How do you proceed in this situation?

28.   You lost some datafiles and you don’t have any full backup and the database was running in NOARCHIVELOG mode. What you can do now?

29.   How do you recover from the loss of datafile if the DB is running in ARCHIVELOG mode?

30.   You loss one datafile and DB is running in ARCHIVELOG mode. You have full database backup of 1 week old and partial backup of this datafile which is just 1 day old. From which backup should you restore this file?

31.   You loss controlfile how do you recover from this?

32.    The current logfile gets damaged. What you can do now?

33.   What is a Complete Recovery?

34.   What is Cancel Based, Time based and Change Based Recovery?

35.   Some user has accidentally dropped one table and you realize this after two days. Can you recover this table if the DB is running in ARCHIVELOG mode?

36.   Do you have to restore Datafiles manually from backups if you are doing recovery using RMAN?

37.   A database is running in ARCHIVELOG mode since last one month. A datafile is added to the database last week. Many objects are created in this datafile. After one week this datafile gets damaged before you can take any backup. Now can you recover this datafile when you don’t have any backups?

38.   How do you recover from the loss of a controlfile if you have backup of controlfile?

39.   Only some blocks are damaged in a datafile. Can you just recover these blocks if you are using RMAN?

40.   Some datafiles were there on a secondary disk and that disk has become damaged and it will take some days to get a new disk. How will you recover from this situation?

41.   Have you faced any emergency situation. Tell us how you resolved it?

42.   At one time you lost parameter file accidentally and you don’t have any backup. How you will recreate a new parameter file with the parameters set to previous values.

43.   What is Consistent Backup?
A Consistent backup is one in which the files being backed up contain all changes upto the same system change number (SCN)

44.   What is fractured Block?
Because the database continues writing to the file during an online backup, there is the possibility of backing up inconsistent data within a block. For example, assume that either RMAN or an operating system utility reads the block while database writer is in the middle of updating the block. In this case, RMAN or the copy utility could read the old data in the top half of the block and the new data in the bottom top half of the block. The block is a fractured block, meaning that the data in this block is not consistent.
45.   What are the steps to performing complete recovery on the whole database?
Mount the database
Ensure that all datafiles you want to recover are online
Restore a backup of the whole database or the files you want to recover
Apply online or archived redo logs, or a combination of the two

46.   What are the steps to performing complete recovery on a tablespace or datafile?
Take the tablespace or datafile to be recovered offline if the database is open
Restore a backup of the datafiles you want to recover
Apply online or archived redo logs, or a combination of the two

47.   What are the components of physical database structure of Oracle database?
Oracle database is comprised of three types of files. One or more datafiles, two are more redo log files, and one or more control files.

48.   What are the components of logical database structure of Oracle database?
There are tablespaces and database’s schema objects.

49.   What is a tablespace?
A database is divided into Logical Storage Unit called tablespaces. A tablespace is used to grouped related logical structures together.

50.   What is SYSTEM tablespace and when is it created?
Every Oracle database contains a tablespace named SYSTEM, which is automatically created when the database is created. The SYSTEM tablespace always contains the data dictionary tables for the entire database.

51.   Explain the relationship among database, tablespace and data file.
Each databases logically divided into one or more tablespaces one or more data files are explicitly created for each tablespace.

52.   What is schema?
A schema is collection of database objects of a user.

53.   What are Schema Objects?
Schema objects are the logical structures that directly refer to the database’s data. Schema objects include tables, views, sequences, synonyms, indexes, clusters, database triggers, procedures, functions packages and database links.

54.   Can objects of the same schema reside in different tablespaces?
Yes.

55.   Can a tablespace hold objects from different schemes?
Yes.

56.   What is Oracle table?
A table is the basic unit of data storage in an Oracle database. The tables of a database hold all of the user accessible data. Table data is stored in rows and columns.

57.   What is an Oracle view?
A view is a virtual table. Every view has a query attached to it. (The query is a SELECT statement that identifies the columns and rows of the table(s) the view uses.)

58.   Do a view contain data?
Views do not contain or store data.

59.   Can a view based on another view?
Yes.

60.   What are the advantages of views?
– Provide an additional level of table security, by restricting access to a predetermined set of rows and columns of a table.
– Hide data complexity.
– Simplify commands for the user.
– Present the data in a different perspective from that of the base table.
– Store complex queries.

61.   What is an Oracle sequence?
A sequence generates a serial list of unique numbers for numerical columns of a database’s tables.

62.   What is a synonym?
A synonym is an alias for a table, view, sequence or program unit.

63.   What are the types of synonyms?
There are two types of synonyms private and public.

64.   What is a private synonym?
Only its owner can access a private synonym.

65.   What is a public synonym?

66.   Any database user can access a public synonym.

67.   What are synonyms used for?
– Mask the real name and owner of an object. – Provide public access to an object – Provide location transparency for tables, views or program units of a remote database. – Simplify the SQL statements for database users.

68.   What is an Oracle index?
An index is an optional structure associated with a table to have direct access to rows, which can be created to increase the performance of data retrieval. Index can be created on one or more columns of a table.

69.   How are the index updates?
Indexes are automatically maintained and used by Oracle. Changes to table data are automatically incorporated into all relevant indexes.

70.   What are clusters?
Clusters are groups of one or more tables physically stores together to share common columns and are often used together.

71.   What is cluster key?
The related columns of the tables in a cluster are called the cluster key.

72.   What is index cluster?
A cluster with an index on the cluster key.

73.   What is hash cluster?
A row is stored in a hash cluster based on the result of applying a hash function to the row’s cluster key value. All rows with the same hash key value are stores together on disk.

74.   When can hash cluster used?
Hash clusters are better choice when a table is often queried with equality queries. For such queries the specified cluster key value is hashed. The resulting hash key value points directly to the area on disk that stores the specified rows.

75.   What is database link?
A database link is a named object that describes a “path” from one database to another.

76.   What are the types of database links?
Private database link, public database link & network database link.

77.   What is private database link?
Private database link is created on behalf of a specific user. A private database link can be used only when the owner of the link specifies a global object name in a SQL statement or in the definition of the owner’s views or procedures.

78.   What is public database link?
Public database link is created for the special user group PUBLIC. A public database link can be used when any user in the associated database specifies a global object name in a SQL statement or object definition.

79.   What is network database link?
Network database link is created and managed by a network domain service. A network database link can be used when any user of any database in the network specifies a global object name in a SQL statement or object definition.

80.   What is data block?
Oracle database’s data is stored in data blocks. One data block corresponds to a specific number of bytes of physical database space on disk.

81.   How to define data block size?
A data block size is specified for each Oracle database when the database is created. A database users and allocated free database space in Oracle data blocks. Block size is specified in init.ora file and cannot be changed latter.

82.   What is row chaining?
In circumstances, all of the data for a row in a table may not be able to fit in the same data block. When this occurs, the data for the row is stored in a chain of data block (one or more) reserved for that segment.

83.   What is an extent?
An extent is a specific number of contiguous data blocks, obtained in a single allocation and used to store a specific type of information.

84.   What is a segment?
A segment is a set of extents allocated for a certain logical structure.

85.   What are the different types of segments?
Data segment, index segment, rollback segment and temporary segment.

86.   What is a data segment?
Each non-clustered table has a data segment. All of the table’s data is stored in the extents of its data segment. Each cluster has a data segment. The data of every table in the cluster is stored in the cluster’s data segment.

87.   What is an index segment?
Each index has an index segment that stores all of its data.

88.   What is rollback segment?
A database contains one or more rollback segments to temporarily store “undo” information.

89.   What are the uses of rollback segment?
To generate read-consistent database information during database recovery and to rollback uncommitted transactions by the users.

90.   What is a temporary segment?
Temporary segments are created by Oracle when a SQL statement needs a temporary work area to complete execution. When the statement finishes execution, the temporary segment extents are released to the system for future use.

91.   What is a datafile?
Every Oracle database has one or more physical data files. A database’s data files contain all the database data. The data of logical database structures such as tablesand indexes is physically stored in the data files allocated for a database.

92.   What are the characteristics of data files?
A data file can be associated with only one database. Once created a data file can’t change size. One or more data files form a logical unit of database storage called a tablespace.

93.   What is a redo log?
The set of redo log files for a database is collectively known as the database redo log.

94.   What is the function of redo log?
The primary function of the redo log is to record all changes made to data.

95.   What is the use of redo log information?
The information in a redo log file is used only to recover the database from a system or media failure prevents database data from being written to a database’s data files.

96.   What does a control file contains?
– Database name – Names and locations of a database’s files and redolog files. – Time stamp of database creation.

97.   What is the use of control file?
When an instance of an Oracle database is started, its control file is used to identify the database and redo log files that must be opened for database operation to proceed. It is also used in database recovery.

Oracle Real time Interview Questions with Answer –7

1) How can you see the Current SCN number of the database?
> Select current_scn from v$database;

2) How can you see the Current log sequence number the logwriter is writing in to?
> Select * from v$log;

3) If you are given a database, how will you know how many datafiles each tablespace contain?
> Select distinct tablespace_name,file_name from dba_data_files;

4). How will you know which temporaray tablepsace is allocated to which user?
> Select temporary_tablespace from dba_users where username=’SCOTT’;

5) If you are given a database,how will you know whether it is locally managed or dictionary managed?
> Select extent_management from dba_tablespaces where tablespace_name=’USERS’;
6) How will you list all the tablespaces and their status in a database?
> Select tablespace_name,status from dba_tablespaces;

7) How will you find the system wide 1) default permanent tablespace, 2) default temporary tablespace 3) Database time zone?
> Select property_name,property_value from database_properties where property_name like ‘%DEFAULT%’;

8) How will you find the current users who are using temporary tablespace segments?
> V$TEMPSEG_USAGE

9) How will you convert an existing dictionary managed permanent tablespace to temporary tablespace?
> Not possible

10) Is media recovery requird if a tablespace is taken offline immediate?
> Not required

11) How will you convert dictionary managed tablespace to locally managed tablespace?
> Exec dbms_space_admin.tablespace_migrate_to_local(‘TABLESPACE_NAME’);

12) If you have given command to make a tablespace offline normal, but its not happening.it is in transactional read-only mode. How will you find which are the transactions which are preventing theconversion?
> By looking at queries using by those SID (u can get script from net). I suspect question is not clear.

13) If you drop a tablespace containing 4 datafiles, how many datafiles will be droped at a time by giving a single drop tablespace command?

> All datafiles

14) If database is not in OMF,How will you drop all the datafiles of a tablespace without dropping the tablespace itself?
> Alter database datafile ‘PATH’ offline drop;

15) How will you convert the locally managed tablespace to dictionay managed?What are the limitations?
> Exec dbms_space_admin.tablespace_migrate_from_local(‘TABLESPACE_NAME’);

SYSTEM tablespace should be dictionary

16) Which parameter defines the max number of datafile in database?
> Db_files and MAXDATAFILES in control file

17) Can a single datafile be allocated to two tablespaces?Why?
> No. because segments cannot space multiple datafiles

18) How will you check if a datafile is Autoextinsible?
> Select autoextensible from dba_data_files where file_name=’’;

19) Write command to make all datafiles of a tablespace offline without making the tablspace offline itself?
> Alter database datafile ‘PATH’ offline normal;

20) In 10g, How to allocate more than one temporary tablespace as default temporary tablespace to a single user?
> By using temporary tablespace group

21) What is the relation between db_files and maxdatafiles parameters?
> Both will restrict no of datafiles in the database

22) Is it possible to make tempfiles as read only?
> yes

23) What is the common column between dba_tablespaces and dba_datafiles?
> Tablespace_name

24) Write a query to display the names of all dynamic performance views?
> Select table_name from dictionary where table_name like ‘v$%’;

25) Name the script that needs to be executed to create the data dictionary views after database creation?
> Catalog.sql

26) Grant to the user SCOTT the RESTRICTED SESSION privilege?
SQL> grant restricted session to scott;
Grant succeeded.

27) How are privileged users being authenticated on the database you are currently working on? Which initialization parameter would give me this information?
> Question not clear

28) Which dynamic performance view gives you information about all privileged users who have been granted sysdba or sysoper roles? Query the view?
SQL> desc v$pwfile_users

29) What is the purpose of the DICTIONARY table?
> To know data dictionary and dynamic performance view names

30) Write a query to display the file# and the status of all datafiles that are offline?
> Select file#,status from v$datafile where status=’OFFLINE’;

31) Write the statement to display the size of the System Global Area (SGA)?
> Show parameter sga
Or
> Show sga

32) Obtain the information about the current database? What is its name and creation date?
> Select name,created from v$database;

33) What is the size of the database buffer cache? Which two initialization Parameters are used to determine this value?

> Db_cache_size or db_block_buffers

34) What value should the REMOTE_LOGIN_PASSWORDFILE take if you need to set up Operating System authentication?
> exclusive

35) Which initialization parameter holds this value? What does the shared pool comprise of?
> Library cache and data dictionary cache.
> Parameter : shared_pool_size

36) Which initialization parameter holds the name of the database?
> Db_name

37) Which dynamic performance view displays information about the active transactions in the database? Which view returns session related information?
> V$transaction, v$session

38) Which dynamic performance view is useful for killing user sessions? Which columns of the view will you require to kill a user session? Write the statement to kill any of the currently active sessions in your database?
> V$session (SID, SERAIL#)
> Alter system kill session ‘SID,SERIAL#’;

39) What is the difference between the ALTER SYSTEM and ALTER SESSION commands?
> Changes performed using ALTER SYSTEM are either permanent for the memory or database. But for ALTER SESSION, its only for that session

40) Write down the mandatory steps that a DBA would need to perform before the CREATE DATABASE command may be used to create a database?
> Create a pfile or spfile
> Create password file
> If windows, create instance using ORADIM utility

41) What does the script utlexcpt.sql create? What is this table used for?

> It will create EXECEPTIONS table. See below link

42) In which Oracle subdirectory are all the SQL scripts such as catalog.sql/ catproc.sql /utlexcpt.sql etc…? Located?
> $ORACLE_HOME/rdbms/admin/

43) Which dynamic performance view would you use to display the OPTIMAL size of the rollback segment RBS2. Write a query to retrieve the OPTIMAL size and Rollback segment name?
> V$undostat (but many scripts are available in google or even in my blog)
44) During a long-running transaction, you receive an error message indicating you have insufficient space in rollback segment RO4. Which storage parameter would you modify to solve this problem?
> Extent size

45) How would I start the database if only users with the RESTRICTED SESSION privilege need to access it?
> Startup restrict

46) Which data dictionary view would you query to find out information about free extents in your database? Write a query to display a count of the number of free extents in your database?
> We can use scripts. Exactly its difficult to know

47) Write a query to display the tablespace name, datafile name and type of extent management (local or dictionary) from the data dictionary?
> You need to combine dba_data_files and dba_tablespaces

48) Which two types of tablespace cannot be taken offline or dropped?
> SYSTEM and UNDO

49) When a tablespace is offline can it be made read only? Perform the
Required steps to confirm your answer?
> Didn’t got the answer

50) Which parameter specifies the percentage of space in each data block that is reserved for future updates?
> PCTFREE
51) write down two reasons why automatic extent allocation for an extent may fail?
> If the disk space reached max limit
> If autoextend reached maxsize limit

52) Query the DBA_CONSTRAINTS view and display the names of all the constraints that are created on the CUSTOMER table?
> Select constraint_name from dba_constraints where table_name=’CUSTOMER’;

53) Write a command to display the names of all BITMAP indexes created in the database?
> Select index_name from dba_indexes where index_type=’BITMAP’;

54) Write a command to coalesce the extents of any index of your choice?
> Alter tablespace coalesce;
> Don’t know for extents

55) . What happens to a row that is bigger than a single block? What is this called? Which data dictionary view can be queried to obtain information about such blocks?
> Row will be chained into multiple blocks. CHAINED_ROWS is the view

56) Write a query to retrieve the employee number and ROWIDs of all rows that belong to the EMP table belonging to user SCOTT?
> Select rowid,empno from scott.emp;

57) During a long-running transaction, you receive an error message indicating you have insufficient space in rollback segment RO4. Which storage parameter would you modify to solve this problem?
> Repeated question

58) How to compile a view? How to compile a table?
> Alter view compile;
> Tables cannot be compiled

59) What is the block size of your database and how do you see it?
> Db_block_size

60) At one time you lost parameter file accidentally and you don’t have any backup. How you will recreate a new parameter file with the parameters set to previous values.?
> We can recover it from alert log file which contains non-default values

61) You want to retain only last 3 backups of datafiles. How do you go for it in RMAN?
> By configuring backup retention policy to redundancy 3

RMAN Backup and Recovery Scenario Point-In-Time Recovery

steps to recover the database:-

1. Take Level 0 backup.
2. Lost SYSTEM datafile.
3. Start the instance without mounting the database.
4. Restore Controlfile.
5. Mount the database.
6. Restore database.
7. Recovery database.
8. Open the database and reset logs.

1. Take Level 0 backup:

run
{
allocate channel channel1 type disk;
allocate channel channel2 type disk;
allocate channel channel3 type disk;
backup incremental level=0 database;
backup archivelog all;
backup current controlfile;
}

2. Lost SYSTEM datafile.

Note:
—-
Need controlfile, backup and parameter file for recoverying database.

3. Start the instance without mounting the database.

$sqlplus “/as sysdba”

SQL> startup nomount;
SQL> exit

4. Restore Controlfile.

$rman target /
RMAN> restore controlfile;

5. Mount the database.
RMAN> alter database mount;

6. Restore and recover & Point-In-Time Recovery of all data back to a particular date/time in the past.
run
{
set until time “to_date(‘2013-03-20:14:40:00′,’YYYY-MM-DD:hh24:mi:ss’)”;
restore database;
recovery database;
}

7.Open the database and reset logs.

SQL> alter database open resetlogs;
This will update all current datafiles and online redo logs and all subsequent archived redo logs with a new RESETLOGS SCN and time stamp.

NOTE:
—-
As soon as you have done a resetlogs run a full backup, this is important as should you suffer a second failure you will not be able to perform a second recovery because after resetting the logs the SCN numbers will no longer match any older backup files.

Oracle backup and recovery Interview Questions and answwer– 5 in oracle

How would you decide your backup strategy and timing for backup?In fact backup strategy is purely depends upon your organization business need.
If no downtime then database must be run on archivelog mode and you have to take frequently or daily backup.
If sufficient downtime is there and loss of data would not affect your business then you can run your database in noarchivelog mode and backup can be taken in-frequently or weekly or monthly.
In most of the case in an organization when no downtime then frequent inconsistent backup needed (daily backup), multiplex online redo log files (multiple copies), different location for redo log files, database must run in archivelog mode and dataguard can be implemented for extra bit of protection.

What is difference between Restoring and Recovery of database?
Restoring means copying the database object from the backup media to the destination where actually it is required where as recovery means to apply the database object copied earlier (roll forward) in order to bring the database into consistent state.

What is the difference between complete and incomplete recovery?An incomplete database recovery is a recovery that it does not reach to the point of failure. The recovery can be either point of time or particular SCN or Particular archive log specially incase of missing archive log or redolog failure where as a complete recovery recovers to the point of failure possibly when having all archive log backup.

What is the benefit of running the DB in archivelog mode over no archivelog mode?
When a database is in no archivelog mode whenever log switch happens there will be a loss of some redoes log information in order to avoid this, redo logs must be archived. This can be achieved by configuring the database in archivelog mode.

If an oracle database is crashed? How would you recover that transaction which is not in backup?If the database is in archivelog we can recover that transaction otherwise we cannot recover that transaction which is not in backup.

What is the difference between HOTBACKUP and RMAN backup?
For hotbackup we have to put database in begin backup mode, then take backup where as RMAN would not put database in begin backup mode. RMAN is faster can perform incremental (changes only) backup, and does not place tablespace in hotbackup mode.

Can we use Same target database as Catalog database?
No, the recovery catalog should not reside in the target database (database to be backed up) because the database can not be recovered in the mounted state.

Incremental backup levels:
Level 0 – full backup that can be used for subsequent incrementals
RMAN> backup incremental level 0 database;
Differential Level 1–only the blocks that have changed since the last backup (whether it is level 0 or level 1)
RMAN> backup incremental level 1 differential database;
Cumulative Level 1 – all changes since the last level 0 incremental backup
RMAN> backup incremental level 1 cumulative database;
A full backup cannot be used for a cumulative level 1 backup.
A cumulative level 1 backup must be done on top of an incremental level 0 backup.

Why RMAN incremental backup fails even though full backup exists?If you have taken the RMAN full backup using the command ‘Backup database’, where as a level 0 backup is physically identical to a full backup. The only difference is that the level 0 backup is recorded as an incremental backup in the RMAN repository so it can be used as the parent for a level 1 backup. Simply the ‘full backup without level 0’ can not be considered as a parent backup from which you can take level 1 backup.

Can we perform RMAN level 1 backup without level 0?If no level 0 is available, then the behavior depends upon the compatibility mode setting (oracle version).
If the compatibility mode less than 10.0.0, RMAN generates a level 0 backup of files contents at the time of backup.
If the compatibility is greater than 10.0.0, RMAN copies all block changes since the file was created, and stores the results as level 1 backup.

How to put Manual/User managed backup in RMAN?In case of recovery catalog, you can put by using catalog command:
RMAN> CATALOG START WITH ‘/oracle/backup.ctl’;

How to check RMAN version in oracle?If you want to check RMAN catalog version then use the below query from SQL*plus
SQL> Select * from rcver;

What happens actually in case of instance Recovery?While Oracle instance fails, Oracle performs an Instance Recovery when the associated database is being re-started. Instance recovery occurs in 2 steps:
Cache recovery: Changes being made to a database are recorded in the database buffer cache as well as redo log files simultaneously. When there are enough data in the database buffer cache, they are written to data files. If an Oracle instance fails before these data are written to data files, Oracle uses online redo log files to recover the lost data when the associated database is re-started. This process is called cache recovery.
Transaction recovery: When a transaction modifies data in a database (the before image of the modified data is stored in an undo segment which is used to restore the original values in case the transaction is rolled back). At the time of an instance failure, the database may have uncommitted transactions. It is possible that changes made by these uncommitted transactions have gotten saved in data files. To maintain read consistency, Oracle rolls back all uncommitted transactions when the associated database is re-started. Oracle uses the undo data stored in undo segments to accomplish this. This process is called transaction recovery.

My Database has Level 1 backup, tell me what are all backed up ? with Example?

Database is UP and has taken Level 0 backup, is the backup taken is Consistent or Inconsistent?

How do you say a backup is Consistent or Inconsistent, Oracle Terminology?

Can we take backup when the Database is down?

If i have a RMAN full backup Level 0 of Sun @9PM, on Mon 9PM taken incremental Level 1 backup.What type of backup do you get and what is actually backedup?

If i have a RMAN full backup of Sun @9PM, on Mon 9PM taken incremental Level 1 backup.On Tuesday Database Crashed.What type of backup do you get and what is actually backedup?

There is no Backup available, Can we take a Level 1 backup?

A table got dropped between 9AM – 11AM how to get the Table backup using RMAN,
DB size 500GB available mount point space for table recovery is 15GB?

Sys Admin has changed the time from 10:00 AM to 9:30 AM, table dropped, How do you recover the Table?

A DATAFILE is corrupted and there is no backup, How to recover the datafile?

All Controlfiles are corrupted, How to recover the controlfile?

Oracle backup and recovery Interview Questions and answwer– 2 in oracle

1. Difference between catalog and nocatalog?
Duplicate Download Pdf Level 1 How to download pdf 7days Catalogs Centrales

2. Difference between using recovery catalog and control file?
When new incarnation happens, the old backup information in control file will be lost. It will be preserved in recovery catalog.
In recovery catalog, we can store scripts.
Recovery catalog is central and can have information of many databases.

3. Can we use same target database as catalog?
No. The recovery catalog should not reside in the target database (database to be backed up), because the database can’t be recovered in the mounted state.

4. How do u know how much RMAN task has been completed?
By querying v$rman_status or v$session_longops

5. From where list & report commands will get input?

6. Command to delete archive logs older than 7days?
RMAN> delete archivelog all completed before sysdate-7;

7. How many days backup, by default RMAN stores?

8. What is the use of crosscheck command in RMAN?
Crosscheck will be useful to check whether the catalog information is intact with OS level information.

9. What are the differences between crosscheck and validate commands?

10. Which is one is good, differential (incremental) backup or cumulative (incremental) backup?
A differential backup, which backs up all blocks changed after the most recent incremental backup at level 1 or 0
A cumulative backup, which backs up all blocks changed after the most recent incremental backup at level 0

11. What is Level 0, Level 1 backup?
A level 0 incremental backup, which is the base for subsequent incremental backups, copies all blocks containing data, backing the datafile up into a backup set just as a full backup would. A level 1 incremental backup can be either of the following types:
A differential backup, which backs up all blocks changed after the most recent incremental backup at level 1 or 0
A cumulative backup, which backs up all blocks changed after the most recent incremental backup at level 0

12. Can we perform level 1 backup without level 0 backup?
If no level 0 backup is available, then the behavior depends upon the compatibility mode setting. If compatibility = 10.0.0, RMAN copies all blocks changed since the file was created, and stores the results as a level 1 backup. In other words, the SCN at the time the incremental backup is taken is the file creation SCN.

13.  Will RMAN put the database/tablespace/datafile in backup mode?
Nope.

14. What is snapshot control file?

15. What is the difference between backup set and backup piece?
Backup set is logical and backup piece is physical.

16. RMAN command to backup for creating standby database?
RMAN> duplicate target database to standby database ….

17. How to do cloning by using RMAN?
RMAN> duplicate target database …

18. You loss one datafile and DB is running in ARCHIVELOG mode. You have full database backup of 1 week/day old and don’t have backup of this (newly created) datafile. How do you restore/recover file?
create the datafile and recover that datafile.
SQL> alter database create datafile ‘…path..’ size n;
RMAN> recover datafile file_id;

19. What is obsolete backup & expired backup?
A status of “expired” means that the backup piece or backup set is not found in the backup destination.
A status of “obsolete” means the backup piece is still available, but it is no longer needed. The backup piece is no longer needed since RMAN has been configured to no longer need this piece after so many days have elapsed, or so many backups have been performed.

20. What is the difference between hot backup & RMAN backup?
For hot backup, we have to put database in begin backup mode, then take backup.
RMAN won’t put database in backup mode.

21. How to put manual/user-managed backup in RMAN (recovery catalog)?
By using catalog command.
RMAN> CATALOG START WITH ‘/tmp/backup.ctl’;

22. What are new features in Oracle 11g RMAN?

23. What is the difference between auxiliary channel and maintenance channel?

Oracle backup and recovery Interview Questions and answwer– 1 in oracle

Q 1
What is SCN?

A 1
The SCN is an Oracle server–assigned number that indicates a committed version of the database. It’s quite possible that different datafiles in the database might have a different SCN at any given point in time.
At checkpoint, the server will makes all database file SCNs and control file SCN consistent with respect to an identical SCN.The datafiles will not contain any database changes beyond that common SCN. This synchronization of the SCNs will make sure we have a consistent backup of database.
When you are doing hot backup, you may end up with backups of the various datafiles at various time points and different SCNs and you can not open a database without synchronizing the SCN on all data files, so you will have to apply archive logs to make the data current and synchronize the SCNs across the datafiles.

Q 2
What is the significance of fast_start_mttr_target parameter?

A 2
You use the Oracle initialization parameter fast_start_mttr_target to specify the number of seconds you want the crash recovery to take. Oracle will try to recover the
instance as close as possible to the time that you specify for the fast_start_mttr_target parameter. The maximum value of this parameter is 3600 seconds (1 hour).

During instance recovery, in the first roll forward operation, the database server must apply all transactions between the last checkpoint and the end of the redo log to the datafiles. Thus, in order to tune instance recovery, you control the gap between the checkpoint position and the end of the redo log. This is called Mean Time to Recover (MTTR).

Q 3
There was a media failure. How can you find which files you must recover?

A 3
By querying the V$RECOVER_FILE view, which lists all files that need media recovery.

Q 4
What are the benefits of RMAN over user-managed backup-recovery process?

A 4
– powerful Data Recovery Advisor feature
– simpler backup and recovery commands
– automatically manages the backup files without DBA intervention.
– automatically deletes unnecessary backup datafiles and archived redo log files both from disk and tape.
– provides you with detailed reporting of backup actions
– Easy to duplicate a database or create standby database.
– Without actually restoring data, you can test whether you will be able to do it or not
– Incremental backup! only RMAN can do that.
– Active Duplication! (11g new feature), you can perform database duplication without backups by using the network enabled database duplication feature
– automatically detects corrupt data blocks during backups
– Data block level recovery possible in case only few DB blocks are corrupt
– Encrypted backups possible
– Use RMAN with a variety of third-party storage systems easily

With so many benefits, RMAN shold be used as primary backup-recovery tool.

Q 5
How important is Database Redundancy Set and where you should plan to keep it?

A 5
Database Redundancy Set is essential set of recovery-related files. As a DBA, you need to be well prepared for any kind of contingency situation.
It should contain below:
– Recent backups of all datafiles & control file (duplex or triplex the control file at database level)
– All archived redo logs made after the last backup
– Current control files and online redo file copies (duplex online redo files at database level)
– Oracle database-related configuration file copies (spfile, password file, tnsnames.ora and listener.ora files etc)

Operating system mirroring is good, but you should do database level mirroring wherever possible.
If you using ASM, try to have atleast Normal redundancy.

When setting up production systems, use at least two disk drives(one for the redundancy set and the other for the datafiles). They should be completely separated by using different volumes, file systems, disk controllers, and RAID devices to hold the two sets of files
You can set up FRA for keeping the redundancy set. Oracle recommends the flash recovery area as a logical candidate to keep a copy of all the files belonging to the redundancy set (which includes the most recent database backup) on disk.

Q 6
What is the benefit of making automatic control file backup to ON?
A 6

Remember that control file is absolutely necessary during a recovery.

Below command can be used to have automatic control file backup to be taken. This is highly recommended.

RMAN> configure controlfile autobackup on

Now at the end of every RMAN backup command, RMAN automatically backs up the control file.

Even when you make some changes via SQL*Plus( say creating a new tablespace or adding or renaming a datafile or an online redo log member), the control file is automatically backed up.

Also, you can restore RMAN’s backup and recovery information (called RMAN’s repository), when you lose all your control files and aren’t using the optional recovery catalog.

Q 7
What is the significance of RMAN view V$RMAN_OUTPUT?

A 7
V$RMAN_OUTPUT displays messages reported by RMAN. This is an in-memory view (means will not persist thru a database restart)and is not recorded in the controlfile. This information straight out of the database by using SQL queries.

Sometimes RMAN log files may have already been overwritten by the next backup or simply just deleted. This is an alternative way of accessing the RMAN output information

For Example:

Review the last two days worth of rman output:

select output
from v$rman_output
where session_recid in (select session_recid from v$rman_status
where start_time > sysdate-2)
order by recid ;

OUTPUT
———————————————————————————————————————————-
connected to target database: BRIJ (DBID=3142459675)
using target database control file instead of recovery catalog

echo set on

backup archivelog all not backed up delete all input;

Starting backup at 09-FEB-14
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=124 instance=BRIJ devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=126 instance=BRIJ devtype=DISK
….

Q 8
What all you can store in Flash Recovery Area(FRA)? Can one FRA directory be used for more than one database?
A 8
Oracle can store different kind of files under FRA:

– backupset: for RMAN regular backups.
– datafile: for RMAN image copies.
– autobackup: for control file autobackups.
– flashback: If your database runs in flashback mode, you will see flashback logs in this subdirectory.
– archivelog: for Archived redo logs
– controlfile: The control file, if configured to go to the flash recovery area.
– onlinelog: Online redo logs can also be made to go to the flash recovery area

You can use the same flash recovery area for as many databases as you want. The RMAN backup process will create a subdirectory called , the same name as the database you are backing up.

Q 9
Which views can be used for Checking Space Usage in the FRA?

A 9

Check Below..

SQL> select NAME,SPACE_LIMIT/1024/1024/1024 TOTAL_GB,SPACE_USED/1024/1024/1024 USED_GB,SPACE_RECLAIMABLE,NUMBER_OF_FILES from v$recovery_file_dest;
NAME TOTAL_GB USED_GB SPACE_RECLAIMABLE NUMBER_OF_FILES
————————————————– ———- ———- —————– —————
/u01/oracle/DB11G/fast_recovery_area 16 1.13197899 0 3

SQL> select * from v$flash_recovery_area_usage;

FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES
——————– —————— ————————- —————
CONTROL FILE 0 0 0
REDO LOG 0 0 0
ARCHIVED LOG .12 0 1
BACKUP PIECE 6.95 0 2
IMAGE COPY 0 0 0
FLASHBACK LOG 0 0 0
FOREIGN ARCHIVED LOG 0 0 0

7 rows selected.

Q 10
Is putting control file and online redo logs in Flash Recovery Area (FRA) advisable?

A 10
Control file is very important file for the database operation. Loosing a single control file will make the database unstable and will lead to interruption in service.
So we will always try to put control file in a safe and stable place.

Similarly online logs are equally important and loosing them can also cause database to crash, incomplete recovery and possible data loss.

CASE 1:
Usually the flash recovery area and the main database disks are located in such a way that the probability of both going down at the same time is very slim.
And If your flash recovery area is in a storage location as reliable as the main database storage, then you should put one control file and one redo member/log group there.
It will surely help you in quick and complete recovery.

CASE 2:
If your flash recovery area is NOT as reliable as the main database storage, the chance of failure in the flash recovery area is greater compared to the main database disks. If the flash recovery area fails, then you lose one of the control files and the online redo log. You will be able to start database easily by removing that control file from the control file parameter in the initialization parameter file (copying online log from the secondary Non-FRA location) and restarting it but you will have an interruption of production service, which is very undesirable.

Scenario A)
Besides FRA, we have multiplexed Control files to two other separate location, so risk of loosing control file (and fear of not able to do complete recovery) is minimized
We won’t be putting even a single control file in the FRA.

Scenario B)
Besides FRA, we have multiplexed Control files to only one other separate location, so risk of loosing control file and (and fear of not able to do complete recovery) is more. Complete recovery of database is of primary importance to you than the database interruption.

Here we can go and put the control file in FRA.

Q 11

How can you make sure that only one of the redo log member is created in FRA?

A 11
If you want only one member of the group in the flash recovery area and the other one in the regular database file location, you should define two parameters—the flash recovery area and db_create_file_dest.

SQL> Show parameter db_recovery_file_dest

NAME TYPE VALUE
———————————— ———– ——————————
db_recovery_file_dest string /u01/oracle/DB11G/fast_recovery_area

SQL> alter system set db_create_file_dest =’/u01/oracle/DB11G/oradata’;

System altered.

SQL> alter database add logfile group 4;

Database altered.

SQL> select * from v$logfile;

GROUP# STATUS TYPE MEMBER IS_RECOVERY_DEST_FILE
———- ——- ——- ————————————————– ———————–
3 ONLINE /u01/oracle/DB11G/oradata/brij/redo03.log NO
2 ONLINE /u01/oracle/DB11G/oradata/brij/redo02.log NO
1 ONLINE /u01/oracle/DB11G/oradata/brij/redo01.log NO
4 ONLINE /u01/oracle/DB11G/oradata/brij/BRIJ/onlinelog/o1_mf_5_9hl8zjmt_.log NO
4 ONLINE /u01/oracle/DB11G/fast_recovery_area/BRIJ/onlinelog/o1_mf_5_9hl8zjsz_.log YES

Q 12

How can you create log of your RMAN activity?

A 12

Two ways to do it

A) WHILE STARTING RMAN

$ rman log=’tmp/rman_log.log’ OR $ rman log /tmp/rman_log.log append

(use with append clause if you don’t wanna overwrite existing file)

Also If you are running RMAN interactively and you want to see output on your terminal screen as well as have it written to a log file, use tee command:

$ rman | tee /tmp/rman.log

B) WHILE INSIDE RMAN

$rman

RMAN> spool log to ‘/tmp/rman_log.log’;

(use with append clause if you don’t wanna overwrite existing file “spool log to ‘/tmp/rman_log.log’ append.)

..
RMAN> spool log off;
** you can use any writeable directory and log file name.

Q 13
Can Recovery Catalog database also be shutdown from RMAN prompt like TARGET Database can be done?

A 13
All the shutdown and startup commands applies only to the target database. You can’t start and stop the recovery catalog instance from RMAN. The only way to start up and shut down the recovery catalog instance is by connecting to the recovery catalog database as the target database and by issuing the relevant commands to start or stop the instance.

Q 14
How to check the syntax of RMAN commands?

A 14

Start the RMAN client with the operating system command-line argument checksyntax.

$ rman checksyntax

Recovery Manager: Release 11.2.0.4.0 – Production on Wed Feb 12 14:36:22 2014

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

RMAN> connect target /

The command has no syntax errors

RMAN> backup database;

The command has no syntax errors

You can also use the checksyntax argument to check the syntax of RMAN commands that are part of a command file.

Example:

$ rman checksyntax @/tmp/rmancmdfile

 Q 15

Does using recovery catalog means RMAN won’t use the control file to store information?

A 15
No. Even when you choose to use a recovery catalog, backup information will continue to be stored in the control file as well by default.

Q 16
What is the benefit of using Recovery Catalog?

A 16

– provides larger storage capacity, thus enabling access to a longer history of backups

– you can create and store RMAN scripts in the recovery catalog and Any client that can connect to the recovery catalog and a target database can use these stored scripts

– Can service many target databases

– you can use ‘KEEP FOREVER’ clause of RMAN backup command.

– Allows you to list the data files and tablespaces that are or  were in the target database at a given time

Q 17
What is the significance of ‘resync catalog’ RMAN command?

A 17
The resync catalog command is used in order to update or resynchronize a recovery catalog from the target database control file. Since sync is done from Target database control file, so you must connect to the recovery catalog as well as to the target database in order to perform the resynchronization.

RMAN> resync catalog;

starting full resync of recovery catalog
full resync complete

When above command is executed, RMAN will first create a snapshot control file. It’ll then compare the contents of the recovery catalog to the contents of the snapshot control file and update the recovery catalog by adding the missing information and modifying the changed backup and schema related records.

It means that we will keep parameter control_file_record_keep_time longer than our backup interval, so that the data in the control file gets transferred to the recovery catalog before that data is overwritten.

When you issue certain RMAN commands such as the backup command, RMAN automatically performs a resynchronization.

Q 18

You want to move your recovery catalog from one database to another. How you can do it?

A 18
Moving Recovery catalog to another database is simple process

a) Create a new recovery catalog in the target database. You don’t need to register any database to it
b) Use the import catalog command in RMAN after connecting to the target database:

$ rman

RMAN> connect catalog rman_new/rman@target_database

RMAN> import catalog rman_old/rman@source_database;

The import catalog command will import the source recovery catalog contents into the target recovery catalog.

Q 19
What are the most important recovery catalog views?

A 19
Below are some of the frequently used views:

RC_STORED_SCRIPT: Information about RMAN scripts stored in the recovery catalog.
RC_UNUSABLE_BACKUPFILE_DETAILS: Lists the unusable backup files recorded in the recovery catalog.
RC_RMAN_STATUS: Similar to V$RMAN_STATUS view and shows the status of all RMAN operations. This view doesn’t contain information about any operations that are currently executing.
RC_RMAN_CONFIGURATION: Information about persistent configuration settings.
RC_DATAFILE: Shows all datafiles registered in the recovery catalog.
RC_DATABASE: Shows the databases registered in the recovery catalog.
RC_ARCHIVED_LOG: Provides historical information on both archived as well as unarchived redo logs.

Q 20
How to check the version of your recovery catalog?

A 20
You can easily check the version of your recovery catalog by issuing the following command from SQL*Plus after logging in as the recovery catalog owner:

RMAN@rmandb > select * from rcver;

VERSION
————
11.02.00.04

Q 21
What all files can NOT be backed up by RMAN?

A 21
1) Oracle home-related files
2) External files
3) Network configuration files
4) Password files

1. Which types of backups you can take in Oracle?

2. A database is running in NOARCHIVELOG mode then which type of backups you can take?

3. Can you take partial backups if the Database is running in NOARCHIVELOG mode?

4. Can you take Online Backups if the the database is running in NOARCHIVELOG mode?

5. How do you bring the database in ARCHIVELOG mode from NOARCHIVELOG mode?

6. You cannot shutdown the database for even some minutes, then in which mode you should run
the database?

7. Where should you place Archive logfiles, in the same disk where DB is or another disk?

8. Can you take online backup of a Control file if yes, how?

9. What is a Logical Backup?

10. Should you take the backup of Logfiles if the database is running in ARCHIVELOG mode?

11. Why do you take tablespaces in Backup mode?

12. What is the advantage of RMAN utility?

13. How RMAN improves backup time?

14. Can you take Offline backups using RMAN?

15. How do you see information about backups in RMAN?

16. What is a Recovery Catalog?

17. Should you place Recovery Catalog in the Same DB?

18. Can you use RMAN without Recovery catalog?

19. Can you take Image Backups using RMAN?

20. Can you use Backupsets created by RMAN with any other utility?

21. Where RMAN keeps information of backups if you are using RMAN without Catalog?

22. You have taken a manual backup of a datafile using o/s. How RMAN will know about it?

23. You want to retain only last 3 backups of datafiles. How do you go for it in RMAN?

24. Which is more efficient Incremental Backups using RMAN or Incremental Export?

25. Can you start and shutdown DB using RMAN?

26. How do you recover from the loss of datafile if the DB is running in NOARCHIVELOG mode?

27. You loss one datafile and it does not contain important objects. The important objects are there in other datafiles which are intact. How do you proceed in this situation?

28. You lost some datafiles and you don’t have any full backup and the database was running in NOARCHIVELOG mode. What you can do now?

29. How do you recover from the loss of datafile if the DB is running in ARCHIVELOG mode?

30. You loss one datafile and DB is running in ARCHIVELOG mode. You have full database backup of 1 week old and backup of only this datafile which is just 1 day old. From which backup should you restore this file?

31. You loss controlfile how do you recover from this?

32. The current logfile gets damaged. What you can do now?

33. What is a Complete Recovery?

34. What is Cancel Based, Time based and Change Based Recovery?

35. Some user has accidentally dropped one table and you realize this after two days. Can you recover this table if the DB is running in ARCHIVELOG mode?

36. Do you have to restore Datafiles manually from backups if you are doing recovery using RMAN?

37. A database is running in ARCHIVELOG mode since last one month. A datafile is added to the database last week. Many objects are created in this datafile. After one week this datafile gets damaged before you can take any backup. Now can you recover this datafile when you don’t have any backups?

38. How do you recover from the loss of a controlfile if you have backup of controlfile?

39. Only some blocks are damaged in a datafile. Can you just recover these blocks if you are using RMAN?

40. Some datafiles were there on a secondary disk and that disk has become damaged and it will take some days to get a new disk. How will you recover from this situation?

41. Have you faced any emergency situation. Tell us how you resolved it?

42. At one time you lost parameter file accidentally and you don’t have any backup. How you will recreate a new parameter file with the parameters set to previous values.