Saturday, June 7, 2008

MANAGING DISTRIBUTED DATABASES.

MANAGING DISTRIBUTED DATABASES.

62. How can we reduce the network traffic ?
- Replictaion of data in distributed environment.
- Using snapshots to replicate data.
- Using remote procedure calls.

63. What is snapshots ?
Snapshot is an object used to dynamically replicate data between distribute database at specified time intervals. In ver 7.0 they are read only.

64. What are the various type of snapshots ?
Simple and Complex.

65. Differentiate simple and complex, snapshots ?
- A simple snapshot is based on a query that does not contains GROUP BY clauses, CONNECT BY clauses, JOINs, sub-query or snashot of operations.
- A complex snapshots contain atleast any one of the above.

66. What dynamic data replication ?
Updating or Inserting records in remote database through database triggers. It may fail if remote database is having any problem.

67. How can you Enforce Refrencial Integrity in snapshots ?
Time the references to occur when master tables are not in use.
Peform the reference the manually immdiately locking the master tables. We can join tables in snopshots by creating a complex snapshots that will based on the master tables.

68. What are the options available to refresh snapshots ?
COMPLETE - Tables are completly regenerated using the snapshot's query and the master tables every time the snapshot referenced.
FAST - If simple snapshot used then a snapshot log can be used to send the changes to the snapshot tables.
FORCE - Default value. If possible it performs a FAST refresh; Otherwise it will perform a complete refresh.

69. what is snapshot log ?
It is a table that maintains a record of modifications to the master table in a snapshot. It is stored in the same database as master table and is only available for simple snapshots. It should be created before creating snapshots.

70. When will the data in the snapshot log be used ?
We must be able to create a after row trigger on table (i.e., it should be not be already available )

After giving table privileges.

We cannot specify snapshot log name because oracle uses the name of the master table in the name of the database objects that support its snapshot log.
The master table name should be less than or equal to 23 characters.
(The table name created will be MLOGS_tablename, and trigger name will be TLOGS name).
72. What are the benefits of distributed options in databases ?
Database on other servers can be updated and those transactions can be grouped together with others in a logical unit.
Database uses a two phase commit.
MANAGING BACKUP & RECOVERY
73. What are the different methods of backing up oracle database ?
- Logical Backups
- Cold Backups
- Hot Backups (Archive log)
74. 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.
75. 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)
76. 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.
77. 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.
78. What is the use of FILE option in EXP command ?
To give the export file name.
79. What is the use of COMPRESS option in EXP command ?
Flag to indicate whether export should compress fragmented segments into single extents.
80. 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'.
81. What is the use of INDEXES option in EXP command ?
A flag to indicate whether indexes on tables will be exported.
82. 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.

83. What is the use of CONSTRAINTS option in EXP command ?
A flag to indicate whether constraints on table need to be exported.
84. What is the use of FULL option in EXP command ?
A flag to indicate whether full databse export should be performed.
85. What is the use of OWNER option in EXP command ?
List of table accounts should be exported.
86. What is the use of TABLES option in EXP command ?
List of tables should be exported.
87. What is the use of RECORD LENGTH option in EXP command ?
Record length in bytes.
88. What is the use of INCTYPE option in EXP command ?
Type export should be performed COMPLETE,CUMULATIVE,INCREMENTAL.
89. What is the use of RECORD option in EXP command ?
For Incremental exports, the flag indirects whether a record will be stores data dictionarytables recording the export.
90. What is the use of PARFILE option in EXP command ?
Name of the parameter file to be passed for export.
91. What is the use of PARFILE option in EXP command ?
Name of the parameter file to be passed for export.
92. 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.
93. 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.
94. What is use of LOG (Ver 7) option in EXP command ?
The name of the file which log of the export will be written.
95.What is the use of FILE option in IMP command ?
The name of the file from which import should be performed.
96. What is the use of SHOW option in IMP command ?
A flag to indicate whether file content should be displayed or not.
97. 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.
98. What is the use of GRANT option in IMP command ?
A flag to indicate whether grants on database objects will be imported.
99. What is the use of INDEXES option in IMP command ?
A flag to indicate whether import should import index on tables or not.
100. 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.
SQL PLUS STATEMENTS
1. What are the types of SQL Statement ?
Data Definition Language : CREATE,ALTER,DROP,TRUNCATE,REVOKE,NO AUDIT & COMMIT.
Data Manipulation Language : INSERT,UPDATE,DELETE,LOCK TABLE,EXPLAIN PLAN & SELECT.
Transactional Control : COMMIT & ROLLBACK
Session Control : ALTERSESSION & SET ROLE
System Control : ALTER SYSTEM.

2. What is a transaction ?

Transaction is logical unit between two commits and commit and rollback.

3. What is difference between TRUNCATE & DELETE ?

TRUNCATE commits after deleting entire table i.e., can not be rolled back. Database triggers do not fire on TRUNCATE

DELETE allows the filtered deletion. Deleted records can be rolled back or committed.
Database triggers fire on DELETE.

4. What is a join ? Explain the different types of joins ?

Join is a query which retrieves related columns or rows from multiple tables.

Self Join - Joining the table with itself.
Equi Join - Joining two tables by equating two common columns.
Non-Equi Join - Joining two tables by equating two common columns.
Outer Join - Joining two tables in such a way that query can also retrive rows that do not have corresponding join value in the other table.

5. What is the Subquery ?

Subquery is a query whose return values are used in filtering conditions of the main query.

6. What is correlated sub-query ?

Correlated sub_query is a sub_query which has reference to the main query.

7. Explain Connect by Prior ?

Retrives rows in hierarchical order.
e.g. select empno, ename from emp where.

8. Difference between SUBSTR and INSTR ?

INSTR (String1,String2(n,(m)),
INSTR returns the position of the mth occurrence of the string 2 in
string1. The search begins from nth position of string1.

SUBSTR (String1 n,m)
SUBSTR returns a character string of size m in string1, starting from nth postion of string1.

9. Explain UNION,MINUS,UNION ALL, INTERSECT ?

INTERSECT returns all distinct rows selected by both queries.
MINUS - returns all distinct rows selected by the first query but not by the second.
UNION - returns all distinct rows selected by either query
UNION ALL - returns all rows selected by either query,including all duplicates.

10. What is ROWID ?

ROWID is a pseudo column attached to each row of a table. It is 18 character long, blockno, rownumber are the components of ROWID.

11. What is the fastest way of accessing a row in a table ?

Using ROWID.

CONSTRAINTS

12. What is an Integrity Constraint ?

Integrity constraint is a rule that restricts values to a column in a table.

13. What is Referential Integrity ?

Maintaining data integrity through a set of rules that restrict the values of one or more columns of the tables based on the values of primary key or unique key of the referenced table.

14. What are the usage of SAVEPOINTS ?

SAVEPOINTS are used to subdivide a transaction into smaller parts. It enables rolling back part of a transaction. Maximum of five save points are allowed.

15. What is ON DELETE CASCADE ?

When ON DELETE CASCADE is specified ORACLE maintains referential integrity by automatically removing dependent foreign key values if a referenced primary or unique key value is removed.

16. What are the data types allowed in a table ?

No comments: