2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-05 12:00:16 +00:00
cheat.sheets/sheets/_db2/queries

33 lines
714 B
Plaintext
Raw Normal View History

2019-01-07 16:57:43 +00:00
--Put a lock at table level
2019-08-06 03:56:21 +00:00
LOCK TABLE tbl1 IN EXCLUSIVE MODE
2019-01-07 16:57:43 +00:00
--Execute a query without regard of commit rows
2019-08-06 03:56:21 +00:00
SELECT * FROM tbl1 WITH UR --RR,RS,CS
2019-01-07 16:57:43 +00:00
--Execute a query with only 5 rows
2019-08-06 03:56:21 +00:00
SELECT * FROM tbl1 FETCH FIRST 5 ROWS ONLY
2019-01-07 16:57:43 +00:00
--Perform a query to a dummy table (dual)
SELECT 'Any string' FROM SYSIBM.SYSDUMMY1
--Perform a query calling a function
2019-08-06 03:56:21 +00:00
SELECT HEX(col2) FROM tbl5
2019-01-07 16:57:43 +00:00
--Call a function
VALUES HEX('AnyText')
--Perform a cast
VALUES CAST('123' AS INTEGER)
--Concatenate
VALUES 'AnyText' || 5
VALUES 'AnyText' concat 5
--Escape a single quote in a text field
VALUES 'Sinead o''Connor'
--Query the database catalog
SELECT * FROM SYSCAT.TABLES
SELECT * FROM SYSCAT.TABAUTH
SELECT * FROM SYSCAT.ROUTINES