Friday, July 13, 2012

Using Postgresql, treat columns as dictionary

Why is Postgresql so lovely?

CREATE EXTENSION hstore;

select (each(hstore(r))).* from (select * from pg_tables limit 1)  as r;

select (each(hstore(r))).key, (each(hstore(r))).value from (select * from pg_tables limit 1)  as r;

select z.key, z.value from ( select (each(hstore(r))).*  from (select * from pg_tables limit 1)  as r ) as z;

Nuff said

Related answer: http://stackoverflow.com/questions/11469059/postgresql-return-entire-row-as-array/11472794#11472794

No comments:

Post a Comment