面试题库之DB2篇—DB2入门到精通

2009年06月12日  |  11:34 下午分类:大型机|Mainframe  |  标签:  |  329 views

Q81) Can I use LOCK TABLE on a view?

A81) No. To lock a view, take lock on the underlying tables.

Q82) What is ALTER ? – GS

A82) SQL command used to change the definition of DB2 objects.

Q83) What is a DBRM, PLAN ?

A83) DBRM: Data Base Request Module, has the SQL statements extracted from the host language program by the pre-compiler. PLAN: A result of the BIND process. It has the executable code for the SQL statements in the DBRM.

Q84) What is ACQUIRE/RELEASE in BIND?

A84) Determine the point at which DB2 acquires or releases locks against table and tablespaces, including intent locks.

Q85) What else is there in the PLAN apart from the access path? – GS

A85) PLAN has the executable code for the SQL statements in the host program

Q86) What happens to the PLAN if index used by it is dropped?

A86) Plan is marked as invalid. The next time the plan is accessed, it is rebound.

Q87) What are PACKAGES ? – GS

A87) They contain executable code for SQL statements for one DBRM.

Q88) What are the advantages of using a PACKAGE?

A88) The advantages of using PACKAGE are:

1. Avoid having to bind a large number of DBRM members into a plan

2. Avoid cost of a large bind

3. Avoid the entire transaction being unavailable during bind and automatic rebind of a plan

4. Minimize fallback complexities if changes result in an error.

Q89) What is a collection?

A89) A user defined name that is the anchor for packages. It has not physical existence. Main usage is to group packages.

Q90) In SPUFI suppose you want to select maximum of 1000 rows, but the select returns only 200 rows. What are the 2 SQLCODEs that are returned? – GS

A90) +100 (for successful completion of the query), 0 (for successful COMMIT if AUTOCOMMIT is set to Yes).

Q91) How would you print the output of an SQL statement from SPUFI? – GS

A91) Print the output dataset.

Q92) Lot of updates have been done on a table due to which indexes have gone haywire. What do you do?

A92) Looks like index page split has occurred. DO a REORG of the indexes.

Q93) What is dynamic SQL? – GS

A93) Dynamic SQL is a SQL statement created at program execution time.

Q94) When is the access path determined for dynamic SQL? – GS

A94) At run time, when the PREPARE statement is issued.

Q95) Suppose I have a program which uses a dynamic SQL and it has been performing well till now. Off late, I find that the performance has deteriorated. What happened? – GS

A95) There may be one of the following reasons:(文章来源:http://www.newcoin.info

Probably RUN STATS is not done and the program is using a wrong index due to incorrect stats.

Probably RUNSTATS is done and optimizer has chosen a wrong access path based on the latest statistics.

Q96) How does DB2 store NULL physically?

A96) As an extra-byte prefix to the column value. Physically, the null prefix is Hex ’00′ if the value is present and Hex ‘FF’ if it is not.

Q97) How do you retrieve the data from a nullable column? – GS

A97) Use null indicators. Syntax … INTO :HOSTVAR:NULLIND

Q98) What is the picture clause of the null indicator variable? – GS

A98) S9(4) COMP.

Q99) What does it mean if the null indicator has -1, 0, -2? – GS

A99) -1 : the field is null; 0 : the field is not null; -2 : the field value is truncated

Q100) How do you insert a record with a nullable column?

A100) To insert a NULL, move -1 to the null indicator, To insert a valid value, move 0 to the null indicator

Q101) What is RUNSTATS? – GS

A101) A DB2 utility used to collect statistics about the data values in tables which can be used by the optimizer to decide the access path. It also collects statistics used for space management. These statistics are stored in DB2 catalog tables.

Q102) When will you chose to run RUNSTATS?

A102) After a load, or after mass updates, inserts, deletes, or after REORG.

Q103) Give some example of statistics collected during RUNSTATS?

A103) Number of rows in the table, Percent of rows in clustering sequence, Number of distinct values of indexed column, Number of rows moved to a nearby/fairway page due to row length increase

Q104) What is REORG? When is it used?

A104) REORG reorganizes data on physical storage to reclutser rows, positioning overflowed rows in their proper sequence, to reclaim space, to restore free space. It is used after heavy updates, inserts and delete activity and after segments of a segmented tablespace have become fragmented.

Q105) What is IMAGECOPY ? – GS

A105) It is full backup of a DB2 table which can be used in recovery.

Q106) When do you use the IMAGECOPY? – GS

A106) To take routine backup of tables, After a LOAD with LOG NO and After REORG with LOG NO

Q107) What is COPY PENDING status?

A107) A state in which, an image copy on a table needs to be taken, In this status, the table is available only for queries. You cannot update this table. To remove the COPY PENDING status, you take an image copy or use REPAIR utility.

Q108) What is CHECK PENDING ?

A108) When a table is LOADed with ENFORCE NO option, then the table is left in CHECK PENDING status. It means that the LOAD utility did not perform constraint checking.

Q109) What is QUIESCE?(文章来源:http://www.newcoin.info

A109) 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.

Q110) What is a clustering index ? – GS

A110) Causes the data rows to be stored in the order specified in the index. A mandatory index defined on a partitioned table space.

Q111) How many clustering indexes can be defined for a table?

A111) Only one.

Q112) What is the difference between primary key & unique index ?

A112) Primary Key: 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.

Q113) What is sqlcode -922 ?(文章来源:http://www.newcoin.info

A113) Authorization failure

Q114) What is sqlcode -811?

A114) SELECT statement has resulted in retrieval of more than one row.

Q115) What does the sqlcode of -818 pertain to? – GS

A115) This is generated when the consistency tokens in the DBRM and the load module are different.

Q116) Are views updatable ?

A116) Not all of them. Some views are updatable e.g. 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.

Q117) If I have a view which is a join of two or more tables, can this view be updatable? – GS

A117) No.

Q118) What are the 4 environments which can access DB2 ?(文章来源:http://www.newcoin.info

A118) TSO, CICS, IMS and BATCH

Q119) What is an inner join, and an outer join ?

A119) 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 all the values 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.

Q120) What is FREEPAGE and PCTFREE in TABLESPACE creation?

A120) PCTFREE: percentage of each page to be left free

FREEPAGE: Number of pages to be loaded with data between each free page





点击查看下一页-Pages:

1 2 3 4 5 6 7 8

喜欢本文,那就收藏到: Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪ViVi 365Key网摘 天极网摘 和讯网摘 博拉网 POCO网摘 添加到饭否 QQ书签 Digbuzz我挖网

1条评论 关于 “面试题库之DB2篇—DB2入门到精通”

  1. killfox 发表于: 六月 13th, 2009 8:52 上午

    偶还是看不懂,太深。

    [回复]


发表您的评论