How can I get all keys from a JSON column in Postgres?

Use this:

select jsonb_object_keys(json_stuff) from table;

(Or just json_object_keys if you’re using just json.)

The PostgreSQL json documentation is quite good. Take a look.

And as it is stated in the documentation, the function only gets the outer most keys. So if the data is a nested json structure, the function will not return any of the deeper keys.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)