PostgreSQL - how to generate an array containing column name and column data...?
The first one can be done using a JSON function

select to_jsonb(n)
from names n;


I have no idea what you want to achieve with the second query.