RSS

Category Archives: FAQ’s

You can see some of the interview frequently asked questions of DataBase Administrator

Check these simple questions

1.        What is Log Switch?
The point at which ORACLE ends writing to one online redo log file and begins writing to another is called a log switch.

2.       What is On-line Redo Log?
The On-line Redo Log is a set of tow or more on-line redo files that record all committed changes made to the database. Whenever a transaction is committed, the corresponding redo entries temporarily stores in redo log buffers of the SGA are written to an on-line redo log file by the background process LGWR. The on-line redo log files are used in cyclical fashion.

3.       Which parameter specified in the DEFAULT STORAGE clause of CREATE TABLESPACE cannot be altered after creating the tablespace?
All the default storage parameters defined for the tablespace can be changed using the ALTER TABLESPACE command. When objects are created their INITIAL and MINEXTENS values cannot be changed.

4.       What are the steps involved in Database Startup?
Start an instance, Mount the Database and Open the Database.

5.        What are the steps involved in Instance Recovery?
Rolling forward to recover data that has not been recorded in data files, yet has been recorded in the on-line redo log, including the contents of rollback segments. Rolling back transactions that have been explicitly rolled back or have not been committed as indicated by the rollback segments regenerated in step a. Releasing any resources (locks) held by transactions in process at the time of the failure. Resolving any pending distributed transactions undergoing a two-phase commit at the time of the instance failure.

6.       Can Full Backup be performed when the database is open?
No.

7.        What are the different modes of mounting a Database with the Parallel Server?
Exclusive Mode If the first instance that mounts a database does so in exclusive mode, only that Instance can mount the database. Parallel Mode If the first instance that mounts a database is started in parallel mode, other instances that are started in parallel mode can also mount the database.

8.       What are the advantages of operating a database in ARCHIVELOG mode over operating it in NO ARCHIVELOG mode?
Complete database recovery from disk failure is possible only in ARCHIVELOG mode. Online database backup is possible only in ARCHIVELOG mode.

9.       What are the steps involved in Database Shutdown?
Close the Database, Dismount the Database and Shutdown the Instance.

10.     What is Archived Redo Log?
Archived Redo Log consists of Redo Log files that have archived before being reused.

11.      What is Restricted Mode of Instance Startup? – An instance can be started in (or later altered to be in) restricted mode so that when the database is open connections are limited only to those whose user accounts have been granted the RESTRICTED SESSION system privilege.

12.     What is Partial Backup?
A Partial Backup is any operating system backup short of a full backup, taken while the database is open or shut down.

13.     What is Mirrored on-line Redo Log?
A mirrored on-line redo log consists of copies of on-line redo log files physically located on separate disks, changes made to one member of the group are made to all members.

14.     What is Full Backup?
A full backup is an operating system backup of all data files, on- line redo log files and control file that constitute ORACLE database and the parameter.

15.     Can a View based on another View?
Yes.

16.     Can a Tablespace hold objects from different Schemes?
Yes.

17.     Can objects of the same Schema reside in different tablespaces?
Yes.

18.     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.

19.     Do View contain Data?
Views do not contain or store data.

20.    What are the Referential actions supported by FOREIGN KEY integrity constraint?
UPDATE and DELETE Restrict – A referential integrity rule that disallows the update or deletion of referenced data. DELETE Cascade – When a referenced row is deleted all associated dependent rows are deleted.

21.     What are the type of Synonyms?
There are two types of Synonyms Private and Public

22.    What is a Redo Log?
The set of Redo Log files YSDATE,UID,USER or USERENV SQL functions, or the pseudo columns LEVEL or ROWNUM.

23.    What is an Index Segment?
Each Index has an Index segment that stores all of its data.

24.    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

25.    What are the different type of Segments?
Data Segment, Index Segment, Rollback Segment and Temporary Segment.

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

27.    What is an Integrity Constrains?
An integrity constraint is a declarative way to define a business rule for a column of a table.

28.    What is an 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.

29.    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.

30.    What is a 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.)

31.     What is 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.

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

33.    What is a Sequence?
A sequence generates a serial list of unique numbers for numerical columns of a database and its tables.

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

35.    What is schema?
A schema is collection of database objects of a User.

36.    Describe Referential Integrity?
A rule defined on a column (or set of columns) in one table that allows the insert or update of a row only if the value for the column or set of columns (the dependent value) matches a value in a column of a related table (the referenced value). It also specifies the type of data manipulation allowed on referenced data and the action to be performed on dependent data as a result of any action on referenced data.

37.    What is Hash Cluster?
A row is stored in a hash cluster based on the result of applying a hash function to the row and its cluster key value. All rows with the same hash key value are stores together on disk.

38.    What is a Private Synonyms?
A Private Synonyms can be accessed only by the owner.

39.    What is Database Link?
database link is a schema object in one database that enables you to access objects on another database

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

41.     What is Rollback Segment?
A Database contains one or more Rollback Segments to temporarily store “undo” information.

42.    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.

43.    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 datablocks. Block size is specified in INIT.ORA file and can’t be changed later.

44.    What does a Control file Contain?
A Control file records the physical structure of the database. It contains the following information. Database Name Names and locations of a database datafiles and redolog files. Time stamp of database creation. When is hot backup taken. Rman config details.

45.    What is difference between UNIQUE constraint and PRIMARY KEY constraint?
A column defined as UNIQUE can contain Nulls while a column defined as PRIMARY KEY cannot contain Nulls.

46.    What is Index Cluster?
A Cluster with an index on the Cluster Key 48.When does a Transaction end? – When it is committed or Rollbacked.

47.    What are the factors that affect OPTIMIZER in choosing an Optimization approach?
The OPTIMIZER_MODE initialization parameter Statistics in the Data Dictionary the OPTIMIZER_GOAL parameter of the ALTER SESSION command hints in the statement.

48.    What is the effect of setting the value ALL_ROWS for OPTIMIZER_GOAL, parameter of the ALTER SESSION Command?
The Optimizer chooses Cost_based approach and optimizes with the goal of best throughput if statistics for atleast one of the tables accessed by the SQL statement exist in the data dictionary. Otherwise the OPTIMIZER chooses RULE_based approach.

49.    What is the function of Optimizer?
The goal of the optimizer is to choose the most efficient way to execute a SQL statement.

50.    What is Execution Plan?
The combinations of the steps the optimizer chooses to execute a statement is called an execution plan.

51.     What are the different approaches used by Optimizer in choosing an execution plan?
Rule-based and Cost-based.

 
1 Comment

Posted by on April 26, 2011 in FAQ's

 

Tags:

FAQ’s

What is a DBA?

A DBA is a Database Administrator, and this is the most common job that you find a database specialist doing. There are Development DBAs and Production DBAs.
A Development DBA usually works closely with a team of developers and gets more involved in design decisions, giving advice on performance and writing good SQL.
That can be satisfying at a human level because you are part of a team and you share the satisfaction of the team’s accomplishments.
A Production DBA (on the other hand) is responsible for maintaining Databases within an organization, so it is a very difficult and demanding job. He or she, often gets involved when all the design decisions have been made, and has simply to keep things up and running.
Therefore, of course, it is also a rewarding job, both financially and in terms of job satisfaction. But it’s a more ‘lonely’ job than being a Development DBA.

1. What DBA activities did you to do today?

This is a loaded question and almost begs for you to answer it with “What DBA activities do you LIKE to do on a daily basis?.” And that is how I would answer this question. Again, do not get caught up in the “typical” day-to-day operational issues of database administration. Sure, you can talk about the index you rebuilt,

the monitoring of system and session waits that were occurring, or the space you added to a data file, these are all good and great and you should convey that you understand the day-to-day operational issues.

What you should also throw into this answer are the meetings that you attend to provide direction in the database arena, the people that you meet and talk with daily to answer adhoc questions about database use, the modeling of business needs within the database, and the extra time you spend early in the morning or late at night to get the job done. Just because the question stipulates “today” do not take “today” to mean “today.” Make sure you wrap up a few good days into “today” and talk about them. This question also begs you to ask the question of “What typical DBA activities are performed day to day within X Corporation?”

2. What are the different modes of mounting a Database with the Parallel Server?

Exclusive Mode If the first instance that mounts a database does so in exclusive mode, only that Instance can mount the database. Parallel Mode If the first instance that mounts a database is started in parallel mode, other instances that are started in parallel mode can also mount the database.

3. What are the advantages of operating a database in ARCHIVELOG mode over operating it in NO ARCHIVELOG mode?

Complete database recovery from disk failure is possible only in ARCHIVELOG mode. Online database backup is possible only in ARCHIVELOG mode.

4. Do you consider yourself a development DBA or a production DBA. why?

You take this as a trick question and explain it that way. Never in my database carrier have I distinguished between “development” and “production.” Just ask your development staff or VP of engineering how much time and money is lost if development systems are down. Explain to the interviewer that both systems are equally important to the operation of the company and both should be considered as production systems because there are people relying on them and money is lost if either one of them is down. Ok you may be saying, and I know you are, that we lose more money if the production system is down. Ok, convey that to the interviewer and you won’t get anyone to disagree with you unless your company sells software or there are million dollar deals on the table that are expecting the next release of your product or service.

5. What are the Large object types supported by Oracle?

Answer1
1)bfile – Up to 4 gigabytes –> File locators that point to a read-only binary object outside of the database
2)blob – Up to 4 gigabytes. –> LOB locators that point to a large binary object within the database
3)clob – Up to 4 gigabytes. –> LOB locators that point to a large character object within the database
4)nclob – Up to 4 gigabytes. –>LOB locators that point to a large NLS character object within the database

Answer2
These are the large object type supported bye oracle
• CLOB and LONG for large fixed-width character data
• NCLOB for large fixed-width national character set data
• BLOB and LONG RAW for storing unstructured data
• BFILE for storing unstructured data in operating system files

6. Differences between a “where” clause and a “having” Claus

Answer1
The order of the clauses in a query syntax using a GROUP BY clause is as follows:
select …where..group by…having…order by…
Where filters, group by arranges into groups, having applies based on group by clause. Having is applied with group by clause.

Answer2
In SQL Server, procedures and functions can return values. (In Oracle, procedures cannot directly return a value).
The major difference with a function is that it can be used in a value assignment. Such as:
–system function
Declare @mydate datetime
Set @mydate = getdate()

–user function (where the user has already coded the function)
Declare @My_area
Set @My_area = dbo.fn_getMy_area(15,20)

Answer3
1.”where” is used to filter records returned by “Select”
2.”where” appears before group by clause
3.In “where” we cannot use aggregate functions like where count(*) >2 etc
4.”Having” appears after group by clause
5.”having” is used to filter records returned by “Group by”<
6.In”Having” we can use aggregate functions like where count (*) >2 etc there are two more

7. Shall we create procedures to fetch more than one record?

Yes. We can create procedures to fetch more than a row. By using CURSOR commands we could able to do that.
Ex:
CREATE OR REPLACE PROCEDURE myprocedure IS
CURSOR my cur IS select id from mytable;
new_id mytable.id%type;
BEGIN
OPEN mycur;
LOOP
FETCH mycur INTO new_id;
exit when mycur%NOTFOUND;
–do some manipulations–
END LOOP;
CLOSE mycur;
END myprocedure;
In this example iam trying to fetch id from the table mytable. So it fetches the id from each record until EOF.

8. Do View contain Data?

Views do not contain or store data.

9. What are the Referential actions supported by FOREIGN KEY integrity constraint?

UPDATE and DELETE Restrict – A referential integrity rule that disallows the update or deletion of referenced data. DELETE Cascade – When a referenced row is deleted all associated dependent rows are deleted.

10. What is the type of Synonyms?

There are two types of Synonyms Private and Public

11. Where would you look for errors from the database engine?

In the alert log.

12. 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.

13. Give the reasoning behind using an index.

Faster access to data blocks in a table.

14. 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.

15. What type of index should you use on a fact table?

A Bitmap index.

16. What is a Segment?

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

17. 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, and enable the foreign key constraint.

18. 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.

19. What is a Sequence?

A sequence generates a serial list of unique numbers for numerical columns of a database’s tables.

20. 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 by picking up controlfile
STARTUP OPEN – The database is opened by checking the files

21. What is a Synonym?

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

22. 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

23. 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.

24. 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.

25. 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.

26. How would you determine the time zone under which a database was operating?

select DBTIMEZONE from dual;

27. 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.

28. What command would you use to encrypt a PL/SQL application?

WRAP

29. 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.

30. 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.

31. Name three advisory statistics you can collect.

Buffer Cache Advice, Segment Level Statistics, & Timed Statistics

32. Where in the Oracle directory tree structure are audit traces placed?

In unix $ORACLE_HOME/rdbms/audit, in Windows the event viewer

33. 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.

34. What does a Control file Contain?

A Control file records the physical structure of the database. It contains the following information. Database Name Names and locations of a database’s files and redolog files. Time stamp of database creation.

35. What is difference between UNIQUE constraint and PRIMARY KEY constraint?

A column defined as UNIQUE can contain Nulls while a column defined as PRIMARY KEY can’t contain Nulls.

36. What is the effect of setting the value “ALL_ROWS” for OPTIMIZER_GOAL parameter of the ALTER SESSION command?

What are the factors that affect OPTIMIZER in choosing an Optimization approach? – Answer The OPTIMIZER_MODE initialization parameter Statistics in the Data Dictionary the OPTIMIZER_GOAL parameter of the ALTER SESSION command hints in the statement.

37. 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.

38. How would you force a log switch?

ALTER SYSTEM SWITCH LOGFILE;

39. What are the different Parameter types?

Text Parameters Data Parameters

40. 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.

41. 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.

42. Name a tablespace automatically created when you create a database.

The SYSTEM tablespace.

43. When creating a user, what permissions must you grant to allow them to connect to the database?

Grant the CONNECT to the user.

44. How do you add a data file to a tablespace?

ALTER TABLESPACE ADD DATAFILE <datafile_name> SIZE <size>

45. How do you resize a data file?

ALTER DATABASE DATAFILE <datafile_name> RESIZE <new_size>;

46. What view would you use to look at the size of a data file?

DBA_DATA_FILES

47. What view would you use to determine free space in a tablespace?

DBA_FREE_SPACE

48. How would you determine who has added a row to a table?

Turn on fine grain auditing for the table.

49. How can you rebuild an index?

ALTER INDEX <index_name> REBUILD;.

50. 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.

51. You have just compiled a PL/SQL package but got errors, how would you view the errors?

SHOW ERRORS

52. How can you gather statistics on a table?

The ANALYZE command.

53. How can you enable a trace for a session?

Use the DBMS_SESSION.SET_SQL_TRACE or
Use ALTER SESSION SET SQL_TRACE = TRUE;

77. What is a schema?

Answer1
The set of objects owned by user account is called the schema.

Answer2
Schema is the complete design of the database or data objects.

78. What are the options available to refresh snapshots?

COMPLETE – Tables are completely regenerated using the snapshots 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.

79. What is a SNAPSHOT LOG?

A snapshot log is a table in the master database that is associated with the master table. ORACLE uses a snapshot log to track the rows that have been updated in the master table. Snapshot logs are used in updating the snapshots based on the master table.

80. What is Distributed database?

A distributed database is a network of databases managed by multiple database servers that appears to a user as single logical database. The data of all databases in the distributed database can be simultaneously accessed and modified.

81. What are the basic element of base configuration of an Oracle database?

It consists of
one or more data files.
one or more control files.
two or more redo log files.
The Database contains
multiple users/schemas
one or more rollback segments
one or more tablespaces
Data dictionary tables
User objects (table,indexes,views etc.,)
The server that access the database consists of
SGA (Database buffer cache, Dictionary Cache, Redo log buffers, Shared pool)
SMON (System Monitor)
PMON (Process Monitor)
LGWR (Log Writer)
DBWR (DataBase Writer)
ARCH (Archiver)
CKPT (Check Point)
RECO(Recoverer)
Dispatcher

82. What is a deadlock? Explain.

Two processes waiting to update the rows of a table, which are locked by other processes then deadlock arises.
In a database environment this will often happen because of not issuing the proper row lock commands. Poor design of front-end application may cause this situation and the performance of server will reduce drastically.
These locks will be released automatically when a commit/rollback operation performed or any one of this processes being killed externally.

83. What is Privilege Auditing?

Privilege auditing is the auditing of the use of powerful system privileges without regard to specifically named objects.

84. What is Object Auditing?

Object auditing is the auditing of accesses to specific schema objects without regard to user.

85. Physical DB Structure

ORACLE db consists of atleast one or more data files, two or more redo log files & one or more control files. The files of a db provide the actual physical storage for db info.

86. Logical DB Structure

schemas, objects (i.e. tables, views, indexes, clusters, sequences). Tablespaces, Segments, Extents.

86. Tablespaces

A database is divided into logical storage units called tablespace. tablespace is used to group related logical structures together. Each database is logically divided into one or more tablespace. One or more data files are explicitly created for each tablespacesto physically store the data of all logical structures in a tablespaces. Combined size of the data file is the total storage capacity of tablespaces. Combined storage capacity of the tablespaces is the total storage capacity of the database.

 
1 Comment

Posted by on April 12, 2011 in FAQ's

 

Tags: