Sunday, November 24, 2013

Custom Variables in Postgres

--set a session variable
set mycustom.var = 'value';

--display it
show mycustom.var; 

--use it
select * from mytable where some_column = current_setting('mycustom.var');

For PG 9.1 or earlier, you would have to add/change this in postgresql.conf:

custom_variable_classes = 'mycustom[,...]'

Restart or SELECT pg_reload_conf();

Sunday, August 18, 2013

Sunday, August 19, 2012

Add comments to tables and columns with PostgreSQL

create table some_table(
  some_column int
);
comment on table some_table is 'some table comment';

comment on column some_table.some_column is 'some column comment';