mirror of
https://github.com/chubin/cheat.sheets
synced 2024-11-19 03:25:44 +00:00
42 lines
1.0 KiB
Plaintext
42 lines
1.0 KiB
Plaintext
--Put a lock at table level
|
||
LOCK TABLE mytable1 IN EXCLUSIVE MODE
|
||
|
||
--Execute a query without regard of commit rows
|
||
SELECT * FROM mytable WITH UR
|
||
|
||
--Execute a query with only 5 rows
|
||
SELECT * FROM mytable FETCH FIRST 5 ROWS ONLY
|
||
|
||
--Perform a query to a dummy table (dual)
|
||
SELECT 'Any string' FROM SYSIBM.SYSDUMMY1
|
||
|
||
--Perform a query calling a function
|
||
SELECT HEX(mycol2) FROM mytable1
|
||
|
||
--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
|
||
|
||
--Create a compound statement – Anonymous block
|
||
BEGIN DECLARE val SMALLINT; SET val = 1; WHILE (val <= 5) DO INSERT INTO mytable VALUES (val, val); SET val = val + 1; END WHILE; END @
|
||
|
||
--Perform a reorg via ADMIN_CMD
|
||
CALL SYSPROC.ADMIN_CMD('REORG TABLE mytable')
|
||
|
||
--Call a stored procedure with an IN and an OUTPUT parameter
|
||
CALL myproc(5, ?)
|