DB2 Interview Questions for Freshers Part – 2

Latest DB2 Interview Questions Part – 2
1.How would you find out the total number of rows in a DB2 table?
Use SELECT COUNT(
*) … in DB2 query
2.How do you eliminate duplicate values in DB2 SELECT?
Use SELECT DISTINCT … in DB2 query
3.How do you select a row using indexes in DB2?
Specify the indexed columns in the WHERE clause of DB2 query.
4.How do you find the maximum value in a column in DB2?
Use SELECT MAX(…) .. in DB2 query .
5.How do you retrieve the first 5 characters of FIRSTNAME column of DB2 table EMP?
SQL Query :
SELECT SUBSTR(FIRSTNAME,1,5) FROM EMP;
6.What is QUIESCE?
A QUIESCE flushes all DB2 buffers on to the disk This gives a correct snapshot of the database and should be used before and after any IMAGECOPY to maintain consistency.
7.What is a Cluster Index?
Causes the data rows to be stored in the order specified in the index A mandatory index defined on a partitioned table space.
8.What is the difference between Primary Key Unique index?
Primary :
a relational database constraint Primary key consists of one or more columns that uniquely identify a row in the table For a normalized relation,there is one designated primary key Unique index: a physical object that stores only unique values There can be one or more unique indexes on a table.
9.What is SQLCODE -922?
Authorization failure
10.What is SQL-811?
SELECT statement has resulted in retrieval of more than one row.
11.What does the SQLCODE -818 pertain to?
This is generated when the consistency tokens in the DBRM and the load module are different.
12.Is View Update is possible?
Not all of them Some views are updatable eg single table view with all the fields or mandatory fields Examples of non-updatable views are views which are joins,views that contain aggregate functions(such as MIN),and views that have GROUP BY clause.
13.What are the 4 environments which can access DB2?
* TSO
* CICS
* IMS
* BATCH
14.What is an inner JOIN,and an outer JOIN?
Inner Join:
combine information from two or more tables by comparing all values that meet the search criteria in the designated column or columns of one table with the entire clause in corresponding columns of the other table or tables. This kind of join which involve a match in both columns are called inner joins.
Outer join:
is one in which you want both matching and non-matching rows to be returned. DB2 has no specific operator for outer joins; it can be simulated by combining a join and a correlated sub query with a UNION.
15.What is FREEPAGE and PCTFREE in TABLESPACE creation?
PCTFREE:
percentage of each page to be left free FREEPAGE: Number of pages to be loaded with data between each free page.
16.What are simple,segmented and partitioned table spaces?
Simple Tablespace:
Can contain one or more tables Rows from multiple tables can be interleaved on a page under the DBAs control and maintenance.
Segmented Tablespace:
Can contain one or more tables Tablespace is divided into segments of 4 to 64 pages in increments of 4 pages. Each segment is dedicated to single table. A table can occupy multiple segments.
Partitioned Tablespace:
Can contain one table Tablespace is divided into parts and each part is put in a separate VSAM dataset.
17.What is filter factor?
One divided by the number of distinct values of a column.
18.What is a SYNONYM?
Synonym is an alternate name for a table or view used mainly to hide the leading Qualifier of a table or view A synonym is accessible only by the creator.
19.What is the difference between SYNONYM and ALIAS?
SYNONYM:
is dropped when the table or table space is dropped Synonym is available only to the creator ALIAS: is retained even if table or table space is dropped ALIAS can be created even if the table does not exist It is used mainly in distributed environment to hide the location info from programs Alias is a global object is available to all.
20.What do you mean by NOT NULL WITH DEFAULT? When will you use it?
This column cannot have nulls and while insertion,if no value is supplied then it wil have zeroes,spaces or date/time depending on whether it is numeric,character or date/time Use it when you do not want to have nulls but at the same time cannot give values all the time you insert this row.
21.When would you prefer to use VARCHAR?
When a column which contains long text,eg remarks,notes,may have in most cases less than 50% of the maximum length.
22.What are the disadvantages of using VARCHAR?
1. Can lead to high space utilization if most of the values are close to MAXIMUM.
2. Positioning of VARCHAR column has to be done carefully as it has performance implications.
3. Relocation of rows to different pages can lead to more I/Os on retrieval.
23.How do I create a table MANAGER ( EMP#,MANAGER) where MANAGER is a foreign key which references to EMP# in the same table?
Give the exact DDL First CREATE MANAGER table with EMP# as the primary key Then ALTER it to define the foreign key.
24.What is auditing?
Recording SQL statements that access a table Specified at table creation time or through alter.
25.What is a DB2 bind?
A DB2 bind is a process that builds an access path to DB2 tables.
26.What is normalization and what are the five normal forms?
Normalization is a design procedure for representing data in tabular format The five normal forms are progressive rules to represent the data with minimal redundancy.
27.What is lock escalation?
Promoting a PAGE lock-size to table or tablespace lock-size when a transaction has acquired more locks than specified in NUMLKTS. Locks should be taken on objects in single tablespace for escalation to occur.
28.What are the various locks available?
SHARE,EXCLUSIVE,UPDATE
29.Can I use LOCK TABLE on a view?
No. To lock a view,take lock on the underlying tables.
30.What is ALTER?
SQL command used to change the definition of DB2 objects.

Related

Interview Questions 1246838860404901567

Post a Comment

emo-but-icon

item