728x90

New SQL syntax using the LIMIT and OFFSET clauses is now supported. The LIMIT clause is helpful when you want to limit the number of records returned by an SQL statement. For example, if the table USERS has 100 records, but you want to return only five records, you can use the following statement:

SELECT * FROM users LIMIT 5

The OFFSET clause indicates how many rows are skipped from the first row to start returning results. For example, if you want to return rows 11 to 15 from the table USERS, you can use the following statement:

SELECT * FROM users LIMIT 5 OFFSET 10

These two clauses are useful when you want to scroll through multiple page results in your code directly from the database rather than filtering them at the application tier.

The LIMIT and OFFSET clauses are enabled by default. However, if you find these clauses are not working, you can ensure they are enabled by executing the following commands:

$ db2set DB2_COMPATIBILITY_VECTOR=MYS
$ db2stop
$ db2start


LIMIT, OFFSET 방식은 MySQL 방식인데 DB2 9.7 fixpak 2부터 지원한다.

다음과 같이 설정할 수도 있다.

$ db2set DB2_COMPATIBILITY_VECTOR=4000


그런데 인포센터에는 해당 내용이 명시되어 있지 않다.



https://www.ibm.com/developerworks/mydeveloperworks/blogs/SQLTips4DB2LUW/entry/limit_offset?lang=en_us

http://www.ibm.com/developerworks/data/library/techarticle/dm-1006db2expressc972/index.html

http://stackoverflow.com/questions/8007243/documentation-for-db2-compatibility-vector-mys-in-db2

728x90

+ Recent posts