Попробуйте использовать CTE
, содержащий array aggregator
. Оператор <@
будет искать точную комбинацию элементов.
WITH j AS (
SELECT table_name, array_agg(column_name::TEXT) AS columns
FROM information_schema.columns
GROUP BY table_name)
SELECT * FROM j
WHERE '{column1,column1}' <@ j.columns
Пример:
WITH j AS (
SELECT table_name, array_agg(column_name::TEXT) AS columns
FROM information_schema.columns
GROUP BY table_name)
SELECT * FROM j
WHERE '{name,statement}' <@ j.columns;
table_name | columns
------------------------+--------------------------------------------------------------------
pg_prepared_statements | {name,statement,prepare_time,parameter_types,from_sql}
pg_cursors | {name,statement,is_holdable,is_binary,is_scrollable,creation_time}
(2 Zeilen)