[DB2] fetch-first-clause

Dev/DB 2012. 7. 20. 13:54

The FETCH FIRST clause limits the number of rows that can be fetched. It

improves the performance of queries with potentially large result tables when only

a limited number of rows are needed.


출처 : DB2® Version 9.1 for z/OS® SQL Reference (SC18-9854-12)


---------------

How to Limit Query Results for DB2 Databases

Many times users are only interested in a subset of the results returned from an SQL query. DB2 provides a mechanism for limiting the records returned from an SQL query with the FETCH FIRST command. Using the FETCH FIRST syntax improves the performance of queries when not all results are required. Listed below are some examples explaining how to use FETCH FIRST.

Example 1: Returning the first 100 rows from a table called employee:

select * from employee fetch first 100 rows only

Example 2: Using the fetch first syntax with an order by clause

select * from employee order by salary desc fetch first 10 rows only 




자세한 정보는 아래 문서에서 확인.

출처 : http://www.razorsql.com/articles/db2_limit_query.html


Posted by pwsunf
,

-613

THE PRIMARY KEY OR A UNIQUE CONSTRAINT IS TOO LONG OR HAS TOO MANY COLUMNS

Explanation

The number of columns that are defined for a PRIMARY KEY or UNIQUE constraint is greater than 64, or the sum of the column length attributes is greater than the number allowed for the type of index.

If the failing statement was an ALTER TABLE statement that included the SET DATA TYPE clause to alter the definition of an existing column, a column being changed is part of a unique or primary constraint. The new sum of the lengths of the columns of the keys exceeds 255-n, where n is the number of columns allowing null values. This sum currently exceeds the maximum number that is allowed.

If the failing statement was an ALTER TABLE statement with a PARTITIONING KEY specification, only 64 columns can be specified, and the combined lengths of all columns specified in the PARTITIONING KEY clause exceeds the maximum length of 255-n, where n is the number of columns that can contain null values.

System action

The statement cannot be processed.

Programmer response

Change the table definition to keep within the prescribed limits.

SQLSTATE

54008


---

테이블 설계 변경...

---

출처 : http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/topic/com.ibm.db2z9.doc.codes/src/tpc/n613.htm

Posted by pwsunf
,

Technote (troubleshooting)


Problem(Abstract)

When you export crawled, analyzed, or searched documents to a relational database, the export fails and “SQL error: SQLCODE=-286, SQLSTATE=42727” is written to the system log in the ES_NODE_ROOT/logs directory.

Cause

Your database mapping file defines a table with more columns than can be contained in the current database table that you created.

Resolving the problem

Delete the database that you created and recreate it with a larger page size. For example, enter the command 

CREATE DB database_name PAGESIZE size.

To determine the page size to specify, check the value of the SQLERRMC parameter in the error message that appears in the export audit log in the ES_NODE_ROOT/logs/audit directory. For example, if the following message appears in the audit log, create a database with a page size of 8192 or higher:

com.ibm.db2.jcc.b.nm: DB2 SQL Error: SQLCODE=-286, SQLSTATE=42727, SQLERRMC=8192 ;DB2ADMIN, DRIVER=3.50.152


출처 : http://www-01.ibm.com/support/docview.wss?uid=swg21414318

------------
pagesize
  • 4K = 4096
  • 8K = 8192
  • 16K = 16384
  • 32K = 32768

Posted by pwsunf
,