Tableless Query for Postgres

Iman Tung
May 16, 2021

--

This kind of query may useful for unit testing.

Query 1: This is working for most SQL

SELECT 'Anto' as name, 12 as age
UNION SELECT 'Linda', 9
UNION SELECT 'Mike', 10

Query 2:

SELECT  *
FROM (values ('Anto', 12),('Linda', 9), ('Mike', 10) ) AS q (name, age)

Query 3: Single column with a lot of data

SELECT id FROM regexp_split_to_table('1,2,3,4,5,7,8,9', ',') AS id

Query 4: To expect more seconds for the query. pg_sleep usually used at blind SQL injection.

SELECT 1 as id, pg_sleep(10)

Previously published in https://imantung.github.io at 15 Sep 2017

--

--

Iman Tung
Iman Tung

Written by Iman Tung

Technology to write, life to grateful. Overthinking is good, only if it has the output. Fundamental is the main concern.

No responses yet