Every so often you might need to find a value regardless of which column it's in. Of course not in application code, as this would be very slow. But you might be in situation where you just don't know where did ...
I got asked this: having this table: # select * from a order by d; t | d ---+---- O | 1 O | 2 O | 3 M | 4 M | 5 M ...
More than once I've seen situation when there is a table, with serial primary key, and rows contain also some kind of creation timestamp, which is usually monotonic, or close to monotonic. Example of such case are for example comments or ...
Let's say you imported some data, but it contains duplicates. You will have to handle them in some way, but to make sensible choice on how to handle it, you need more information. So, let's start. We have table: # \d users ...
Let's imagine following situation: create table test (id int4 primary key, priority int4); insert into test (id) select distinct (random() * 100000000)::int4 from generate_series(1,1000); Table test will now contain some (up to 1000) records, with random ids. Now, we want to ...
Let's assume you have very simple table with users: # \d users Table "public.users" ...
cortilap @ freenode's #postgresql asked about how to create a check() that will allow only one of the columns to be not null. it doesn't sound cool, let's see: with 2 columns (a,b) you make a check: check ( (a is not ...
faber4 on irc asked about how to get ascii-based sorting, while his postgresql was initdb'ed with utf-8 based locale (en_US.UTF-8 to be exact). what can we do about it?
luckymurali_81 on freenodes #postgresql had a problem. his query returns data in wrong order. what can we do about it?
mage_ from #postgresql had interesting problem today. he has a table with 2 date fields, and he wants to have list of all years from both fields. together. as one list. his approach: select date_part('year', date1) from test union select date_part('year', date2) from test; is hardly ...
