Saturday, 27 February 2016

BACKUP & RECOVERY COMMANDS AND QUESTIONS

MANAGING BACKUP & RECOVERY
What are the different methods of backing up oracle database ?
-Logical Backups 
- Cold Backups 
- Hot Backups (Archive log)
What is a logical backup ?
Logical backup involves reading a set of databse records and writing them into a file. Export utility is used for taking backup and Import utility is used to recover from backup.
What is cold backup ? What are the elements of it ?
Cold backup is taking backup of all physical files after normal shutdown of database. We need to take.
- All Data files. - All Control files. - All on-line redo log files. - The init.ora file (Optional)
What are the different kind of export backups ?
Full back - Complete database. Incremental - Only affected tables from last incremental date/full backup date. Cumulative backup - Only affected table from the last cumulative date/full backup date.
What is hot backup and how it can be taken ?
Taking backup of archive log files when database is open. For this the ARCHIVELOG mode should be enabled. The following files need to be backed up.  All data files. All Archive log, redo log files. All control files.
What is the use of FILE option in EXP command ?
To give the export file name.
What is the use of COMPRESS option in EXP command ?
Flag to indicate whether export should compress fragmented segments into single extents.
What is the use of GRANT option in EXP command ?
A flag to indicate whether grants on databse objects will be exported or not. Value is 'Y' or 'N'.
What is the use of INDEXES option in EXP command ?
A flag to indicate whether indexes on tables will be exported.
What is the use of ROWS option in EXP command ?
Flag to indicate whether table rows should be exported. If 'N' only DDL statements for the databse objects will be created.
What is the use of CONSTRAINTS option in EXP command ?
A flag to indicate whether constraints on table need to be exported.
What is the use of FULL option in EXP command ?
A flag to indicate whether full databse export should be performed.
What is the use of OWNER option in EXP command ?List of table accounts should be exported.
What is the use of TABLES option in EXP command ?
List of tables should be exported.
What is the use of RECORD LENGTH option in EXP command ?
Record length in bytes.
What is the use of INCTYPE option in EXP command ?
Type export should be performed COMPLETE,CUMULATIVE,INCREMENTAL.
What is the use of RECORD option in EXP command ?
For Incremental exports, the flag indirects whether a record will be stores data dictionary tables recording the export.
What is the use of PARFILE option in EXP command ?
Name of the parameter file to be passed for export.
What is the use of PARFILE option in EXP command ?
Name of the parameter file to be passed for export.
What is the use of ANALYSE ( Ver 7) option in EXP command ?
A flag to indicate whether statistical information about the exported objects should be written to export dump file.
What is the use of CONSISTENT (Ver 7) option in EXP command ?
A flag to indicate whether a read consistent version of all the exported objects should be maintained.
What is use of LOG (Ver 7) option in EXP command ?
The name of the file which log of the export will be written.
What is the use of FILE option in IMP command ?
The name of the file from which import should be performed.
What is the use of SHOW option in IMP command ?
A flag to indicate whether file content should be displayed or not.
What is the use of IGNORE option in IMP command ?
A flag to indicate whether the import should ignore errors encounter when issuing CREATE commands.
What is the use of GRANT option in IMP command ?
A flag to indicate whether grants on database objects will be imported.
What is the use of INDEXES option in IMP command ?
A flag to indicate whether import should import index on tables or not.
What is the use of ROWS option in IMP command ?
A flag to indicate whether rows should be imported. If this is set to 'N' then only DDL for database objects will be exectued.

ORACLE TECHNICAL

Technical Oracle:
1.     Explain the difference between a hot backup and a cold backup and the benefits associated with each.
A hot backup is basically taking a backup of the database while it is still up and running and it must be in archive log mode. A cold backup is taking a backup of the database while it is shut down and does not require being in archive log mode. The benefit of taking a hot backup is that the database is still available for use while the backup is occurring and you can recover the database to any point in time. The benefit of taking a cold backup is that it is typically easier to administer the backup and recovery process. In addition, since you are taking cold backups the database does not require being in archive log mode and thus there will be a slight performance gain as the database is not cutting archive logs to disk.
2.     You have just had to restore from backup and do not have any control files. How would you go about bringing up this database?
I would create a text based backup control file, stipulating where on disk all the data files where and then issue the recover command with the using backup control file clause.
3.     How do you switch from an init.ora file to a spfile?
Issue the create spfile from pfile command.
4.     Explain the difference between a data block, an extent and a segment.
A data block is the smallest unit of logical storage for a database object. As objects grow they take chunks of additional storage that are composed of contiguous data blocks. These groupings of contiguous data blocks are called extents. All the extents that an object takes when grouped together are considered the segment of the database object.
5.     Give two examples of how you might determine the structure of the table DEPT.
Use the describe command or use the dbms_metadata.get_ddl package.
6.     Where would you look for errors from the database engine?
In the alert log.
7.     Compare and contrast TRUNCATE and DELETE for a table.
Both the truncate and delete command have the desired outcome of getting rid of all the rows in a table. The difference between the two is that the truncate command is a DDL operation and just moves the high water mark and produces a now rollback. The delete command, on the other hand, is a DML operation, which will produce a rollback and thus take longer to complete.
8.     Give the reasoning behind using an index.
Faster access to data blocks in a table.
9.     Give the two types of tables involved in producing a star schema and the type of data they hold.
Fact tables and dimension tables. A fact table contains measurements while dimension tables will contain data that will help describe the fact tables.
10. . What type of index should you use on a fact table?
A Bitmap index.
11. Give two examples of referential integrity constraints.
A primary key and a foreign key.
12. A table is classified as a parent table and you want to drop and re-create it. How would you do this without affecting the children tables?
Disable the foreign key constraint to the parent, drop the table, re-create the table, enable the foreign key constraint.
13. Explain the difference between ARCHIVELOG mode and NOARCHIVELOG mode and the benefits and disadvantages to each.
ARCHIVELOG mode is a mode that you can put the database in for creating a backup of all transactions that have occurred in the database so that you can recover to any point in time. NOARCHIVELOG mode is basically the absence of ARCHIVELOG mode and has the disadvantage of not being able to recover to any point in time. NOARCHIVELOG mode does have the advantage of not having to write transactions to an archive log and thus increases the performance of the database slightly.
14. What command would you use to create a backup control file?
Alter database backup control file to trace.
15. Give the stages of instance startup to a usable state where normal users may access it.
STARTUP NOMOUNT - Instance startup
STARTUP MOUNT - The database is mounted
STARTUP OPEN - The database is opened
16. What column differentiates the V$ views to the GV$ views and how?
The INST_ID column which indicates the instance in a RAC environment the information came from.
17. How would you go about generating an EXPLAIN plan?
Create a plan table with utlxplan.sql.
Use the explain plan set statement_id = 'tst1' into plan_table for a SQL statement
Look at the explain plan with utlxplp.sql or utlxpls.sql
18. How would you go about increasing the buffer cache hit ratio?
Use the buffer cache advisory over a given workload and then query the v$db_cache_advice table. If a change was necessary then I would use the alter system set db_cache_size command.
19. Explain an ORA-01555
You get this error when you get a snapshot too old within rollback. It can usually be solved by increasing the undo retention or increasing the size of rollbacks. You should also look at the logic involved in the application getting the error message.
20. Explain the difference between $ORACLE_HOME and $ORACLE_BASE.
ORACLE_BASE is the root directory for oracle. ORACLE_HOME located beneath ORACLE_BASE is where the oracle products reside.
21.  How would you determine the time zone under which a database was operating?
select DBTIMEZONE from dual;
22.  Explain the use of setting GLOBAL_NAMES equal to TRUE.
Setting GLOBAL_NAMES dictates how you might connect to a database. This variable is either TRUE or FALSE and if it is set to TRUE it enforces database links to have the same name as the remote database to which they are linking.
23.  What command would you use to encrypt a PL/SQL application?
WRAP
24.  Explain the difference between a FUNCTION, PROCEDURE and PACKAGE.
A function and procedure are the same in that they are intended to be a collection of PL/SQL code that carries a single task. While a procedure does not have to return any values to the calling application, a function will return a single value. A package on the other hand is a collection of functions and procedures that are grouped together based on their commonality to a business function or application.
25.  Explain the use of table functions.
Table functions are designed to return a set of rows through PL/SQL logic but are intended to be used as a normal table or view in a SQL statement. They are also used to pipeline information in an ETL process.
26.  Name three advisory statistics you can collect.
Buffer Cache Advice, Segment Level Statistics, & Timed Statistics
27.  Where in the Oracle directory tree structure are audit traces placed?
In unix $ORACLE_HOME/rdbms/audit, in Windows the event viewer
28.  Explain materialized views and how they are used.
Materialized views are objects that are reduced sets of information that have been summarized, grouped, or aggregated from base tables. They are typically used in data warehouse or decision support systems.
29.  When a user process fails, what background process cleans up after it?
PMON
30.  What background process refreshes materialized views?
The Job Queue Processes.
31.  How would you determine what sessions are connected and what resources they are waiting for?
Use of V$SESSION and V$SESSION_WAIT
32.  Describe what redo logs are.
Redo logs are logical and physical structures that are designed to hold all the changes made to a database and are intended to aid in the recovery of a database.
33.  How would you force a log switch?
ALTER SYSTEM SWITCH LOGFILE;
34.  Give two methods you could use to determine what DDL changes have been made.
You could use Logminer or Streams
35.  What does coalescing a tablespace do?
Coalescing is only valid for dictionary-managed tablespaces and de-fragments space by combining neighboring free extents into large single extents.
36.  What is the difference between a TEMPORARY tablespace and a PERMANENT tablespace?
A temporary tablespace is used for temporary objects such as sort structures while permanent tablespaces are used to store those objects meant to be used as the true objects of the database.
37.  Name a tablespace automatically created when you create a database.
The SYSTEM tablespace.
38.  When creating a user, what permissions must you grant to allow them to connect to the database?
Grant the CONNECT to the user.
39.  How do you add a data file to a tablespace?
ALTER TABLESPACE <tablespace_name> ADD DATAFILE <datafile_name> SIZE <size>
40.  How do you resize a data file?
ALTER DATABASE DATAFILE <datafile_name> RESIZE <new_size>;
41.  What view would you use to look at the size of a data file?
DBA_DATA_FILES
42.  What view would you use to determine free space in a tablespace?
DBA_FREE_SPACE
43.  How would you determine who has added a row to a table?
Turn on fine grain auditing for the table.
44.  How can you rebuild an index?
ALTER INDEX <index_name> REBUILD;
45.  Explain what partitioning is and what its benefit is.
Partitioning is a method of taking large tables and indexes and splitting them into smaller, more manageable pieces.
46.  You have just compiled a PL/SQL package but got errors, how would you view the errors?
SHOW ERRORS
47.  How can you gather statistics on a table?
The ANALYZE command.
48.  How can you enable a trace for a session?
Use the DBMS_SESSION.SET_SQL_TRACE or
Use ALTER SESSION SET SQL_TRACE = TRUE;
49.  What is the difference between the SQL*Loader and IMPORT utilities?
These two Oracle utilities are used for loading data into the database. The difference is that the import utility relies on the data being produced by another Oracle utility EXPORT while the SQL*Loader utility allows data to be loaded that has been produced by other utilities from different data sources just so long as it conforms to ASCII formatted or delimited files.
50.  Name two files used for network connection to a database.
TNSNAMES.ORA and SQLNET.ORA
51. Ask 'How would you identify the bottlenecks in Database performance ?'
The answer is to examine the Oracle Execution Plan, and to make sure that the  appropriate Indexes exist and are used by the Oracle Optimizer.
52. Ask 'How do you find the numbert of rows in a Table ?'
A bad answer is count them (SELECT COUNT(*) FROM table_name)    A good answer is :-    'By generating SQL to ANALYZE TABLE table_name COUNT STATISTICS  by querying Oracle System Catalogues (e.g. USER_TABLES or ALL_TABLES). The best answer is to refer to the utility which Oracle released which makes it unnecessary to do ANALYZE TABLE for each Table individually.

ORACLE DBA

Oracle DBA
SNAPSHOT is used for[DBA] a] Synonym, b] Table space, c] System server, d] Dynamic data
replication Ans : D
We can create SNAPSHOTLOG for[DBA] a] Simple snapshots, b] Complex snapshots, c] Both A & B, d]
Neither A nor B Ans : A
Transactions per rollback segment is derived from[DBA] a] Db_Block_Buffers, b] Processes, c] Shared_Pool_Size, d] None
of the above Ans : B
ENQUEUE resources parameter information is derived from[DBA] a] Processes or DDL_LOCKS and DML_LOCKS, b] LOG_BUFFER,
c] DB__BLOCK_SIZE.. Ans : A
LGWR process writes information intoa] Database files, b] Control files, c] Redolog files, d] All the
above. Ans : C
SET TRANSACTION USE ROLLBACK SEGMENT is used to create user
objects in a particular Tablespace

a] True, b] False Ans : False
Databases overall structure is maintained in a file calleda] Redolog file, b] Data file, c] Control file, d] All of the above. Ans : C
These following parameters are optional in init.ora parameter file DB_BLOCK_SIZE, PROCESSES a] True, b] FalseAns : False
Constraints cannot be exported through EXPORT command a] True, b] FalseAns : False
It is very difficult to grant and manage common privileges needed by different groups of database users using the roles a] True, b] FalseAns : False
What is a triggera] A piece of logic written in PL/SQL b] Executed at the arrival of a SQL*FORMS event c] Both A & B d] None of the above
Ans : C
Which of the folowing is TRUE for a ERASE packaged procedure1] ERASE removes an indicated Global variable & releases the memory
associated with it 2] ERASE is used to remove a field from a page 1] Only 1 is TRUE 2] Only 2 is TRUE 3] Both 1 & 2 are TRUE 4] Both 1 & 2 are FALSE
Ans : 1
All datafiles related to a Tablespace are removed when the Tablespace is droppeda] TRUE b] FALSE
Ans : B
Size of Tablespace can be increased bya] Increasing the size of one of the Datafiles b] Adding one or more Datafiles c] Cannot be increased d] None of the above
Ans : B
Multiple Tablespaces can share a single datafilea] TRUE b] FALSE
Ans : B
A set of Dictionary tables are createda] Once for the Entire Database b] Every time a user is created c] Every time a Tablespace is created d] None of the above
Ans : A
Datadictionary can span across multiple Tablespaces a] TRUE b] FALSE
Ans : B
What is a DATABLOCKa] Set of Extents b] Set of Segments c] Smallest Database storage unit d] None of the above
Ans : C
Can an Integrity Constraint be enforced on a table if some existing table data does not satisfy the constraint a] Yes b] No
Ans : B
A column defined as PRIMARY KEY can have NULL's a] TRUE b] FALSE
Ans : B
A Transaction ends a] Only when it is Committed b] Only when it is Rolledback c] When it is Committed or Rolledback d] None of the above
Ans : C
A Database Procedure is stored in the Databasea] In compiled form b] As source code c] Both A & B d] Not stored
Ans : C
A database trigger doesnot apply to data loaded before the definition of the trigger a] TRUE b] FALSE
Ans : A
Dedicated server configuration is
a] One server process - Many user processes b] Many server processes - One user process c] One server process - One user process d] Many server processes - Many user processes
Ans : C
Which of the following does not affect the size of the SGAa] Database buffer b] Redolog buffer c] Stored procedure d] Shared pool
Ans : C
What does a COMMIT statement do to a CURSORa] Open the Cursor b] Fetch the Cursor c] Close the Cursor d] None of the above
Ans : D
Which of the following is TRUE
1] Host variables are declared anywhere in the program
2] Host variables are declared in the DECLARE section 
a] Only 1 is TRUE b] Only 2 is TRUE c] Both 1 & 2are TRUE d] Both are FALSE
Ans : B
Which of the following is NOT VALID is PL/SQLa] Bool boolean; b] NUM1, NUM2 number; c] deptname dept.dname%type; d] date1 date := sysdate
Ans : B
Q)Declare  fvar number := null; svar number := 5 Begin goto << fproc>> if fvar is null then  << fproc>>
svar := svar + 5 end if; End; 
What will be the value of svar after the execution ?
a] Error b] 10 c] 5 d] None of the above
Ans : A
Which of the following is not correct about an Exception ?
a] Raised automatically / Explicitly in response to an ORACLE_ERROR b] An exception will be raised when an error occurs in that block c] Process terminates after completion of error sequence. d] A Procedure or Sequence of statements may be processed.
Ans : C
Which of the following is not correct about User_Defined Exceptions ?a] Must be declared b] Must be raised explicitly c] Raised automatically in response to an Oracle error d] None of the above
Ans : C
A Stored Procedure is aa] Sequence of SQL or PL/SQL statements to perform specific function  b] Stored in compiled form in the database c] Can be called from all client environments d] All of the above
Ans : D
Which of the following statement is falsea] Any procedure can raise an error and return an user message and error number b] Error number ranging from 20000 to 20999 are reserved for user defined messages c] Oracle checks Uniqueness of User defined errors d] Raise_Application_error is used for raising an user defined error.
Ans : C
Is it possible to open a cursor which is in a Package in another procedure ? a] Yes b] No
Ans : A
Is it possible to use Transactional control statements in Database Triggers ? a] Yes b] No
Ans : B
Is it possible to Enable or Disable a Database trigger ? a] Yes b] No
Ans : A
PL/SQL supports datatype(s) a] Scalar datatype b] Composite datatype c] All of the above d] None of the above
Ans C
Find the ODD datatype outa] VARCHAR2 b] RECORD c] BOOLEAN d] RAW
Ans : B
Which of the following is not correct about the "TABLE" datatype ?a] Can contain any no of columns b] Simulates a One-dimensional array of unlimited size c] Column datatype of any Scalar type d] None of the above
Ans : A
Find the ODD one out of the followinga] OPEN b] CLOSE c] INSERT d] FETCH
Ans C
Which of the following is not correct about Cursor ?a] Cursor is a named Private SQL area b] Cursor holds temporary results c] Cursor is used for retrieving multiple rows d] SQL uses implicit Cursors to retrieve rows
Ans : B
Which of the following is NOT VALID in PL/SQL ?a] Select ... into b] Update c] Create d] Delete
Ans : C
What is the Result of the following 'VIK'||NULL||'RAM' ?a] Error b] VIK RAM c] VIKRAM d] NULL
Ans : C
Q)Declare a number := 5; b number := null; c number := 10; Begin if a > b AND a < c then a := c * a; end if; End; 
What will be the value of 'a' after execution ?a] 50 b] NULL c] 5 d] None of the above
Ans : C
Does the Database trigger will fire when the table is TRUNCATED ? a] Yes b] No
Ans : B
68. SUBSTR(SQUARE ANS ALWAYS WORK HARD,14,6) will return a] ALWAYS b} S ALWA c] ALWAYS
Ans : C
REPLACE('JACK AND JUE','J','BL') will returna] JACK AND BLUE b] BLACK AND JACK c] BLACK AND BLUE d] None of the above
Ans : C
TRANSLATE('333SQD234','0123456789ABCDPQRST','0123456789') will returna] 333234 b] 333333  c] 234333 d] None of the above
Ans : A
EMPNO ENAME SAL A822 RAMASWAMY 3500 A812 NARAYAN 5000 A973 UMESH 2850 A500 BALAJI 5750 Use these data for the following Questions Select SAL from EMP E1 where 3 > ( Select count(*) from Emp E2 where E1.SAL > E2.SAL ) will retrieve 
a] 3500,5000,2500 b] 5000,2850 c] 2850,5750 d] 5000,5750
Ans : A
Is it possible to modify a Datatype of a column when column contains data ? a] Yes b] No
Ans B
Which of the following is not correct about a View ?a] To protect some of the columns of a table from other users b] Ocuupies data storage space c] To hide complexity of a query d] To hide complexity of a calculations
Ans : B
Which is not part of the Data Definiton Language ?  a] CREATE b] ALTER c] ALTER SESSION
Ans : C
The Data Manipulation Language statements are a] INSERT b] UPDATE c] SELECT d] All above
Ans : D
EMPNO ENAME SAL A822 RAMASWAMY 3500 A812 NARAYAN 5000 A973 UMESH A500 BALAJI 5750 Using the above data Select count(sal) from Emp will retrieve a] 1 b] 0 c] 3 d] None of the above
Ans : C
If an UNIQUE KEY constraint on DATE column is created, will it accept the rows that are inserted with SYSDATE ? a] Will b] Won't
Ans : B
What are the different events in Triggers ? a] Define, Create b] Drop, Comment c] Insert, Update, Delete d] All of the above
Ans : C
Sequence of events takes place while starting a Database is a] Database opened, File mounted, Instance started b] Instance started, Database mounted & Database opened c] Database opened, Instance started & file mounted d] Files mounted, Instance started & Database opened
Ans : B
SYSTEM TABLESPACE can be made off-line a] Yes b] No
Ans : B
ENQUEUE_RESOURCES parameter information is derived froma] PROCESS or DDL_LOCKS & DML_LOCKS b] LOG BUFFER c] DB_BLOCK_SIZE d] DB_BLOCK_BUFFERS
Ans : A
SMON process is used to write into LOG files a] TRUE b] FALSE
Ans : B
EXP command is used  a] To take Backup of the Oracle Database b] To import data from the exported dump file c] To create Rollback segments d] None of the above
Ans : A
SNAPSHOTS cannot be refreshed automatically a] TRUE b] FALSE
Ans : B
The User can set Archive file name formats a] TRUE b] FALSE
Ans : A
The following parameters are optional in init.ora parameter file DB_BLOCK_SIZE, PROCESS
a} TRUE b] FALSE
Ans : B
NOARCHIEVELOG parameter is used to enable the database in Archieve mode
a] TRUE b] FALSE
Ans : B
Constraints cannot be exported through Export command? a] TRUE b] FALSE
Ans : B
It is very difficult to grant and manage common priveleges needed by different groups of database users using roles a] TRUE b] FALSE
Ans : B
The status of the Rollback segment can be viewed througha] DBA_SEGMENTS b] DBA_ROLES c] DBA_FREE_SPACES d] DBA_ROLLBACK_SEG
Ans : D
Explicitly we can assign transaction to a rollback segment a] TRUE B] FALSE
Ans : A
What file is read by ODBC to load drivers ?a] ODBC.INI b] ODBC.DLL c] ODBCDRV.INI d] None of the above
Ans : A