PostgreSQL
 sql >> Database >  >> RDS >> PostgreSQL

Seleziona tutte le colonne tranne alcune PostgreSQL

Funziona:

CREATE TABLE public.office(id INTEGER, a TEXT, b TEXT, deleted BOOLEAN, c TEXT)

Quindi:

SELECT 'SELECT ' || STRING_AGG('o.' || column_name, ', ') || ' FROM office AS o'
FROM information_schema.columns
WHERE table_name = 'office'
AND table_schema = 'public'
AND column_name NOT IN ('id', 'deleted')

Risultato:

SELECT o.a, o.b, o.c FROM office AS o