Re: [SQL] \copy multiline

2012-11-29 Thread Sebastian P . Luque
On Thu, 29 Nov 2012 10:33:37 +0100, Guillaume Lelarge wrote: > On Wed, 2012-11-28 at 21:21 -0600, Seb wrote: >> Hi, >> I use \copy to output tables into CSV files: >> \copy (SELECT ...) TO 'a.csv' CSV >> but for long and complex SELECT statements, it is cumbersome and >> confusing to write eve

Re: [SQL] \copy multiline

2012-11-29 Thread Sebastian P . Luque
On Thu, 29 Nov 2012 08:01:31 +, Ben Morrow wrote: > Quoth splu...@gmail.com (Seb): >> I use \copy to output tables into CSV files: >> \copy (SELECT ...) TO 'a.csv' CSV >> but for long and complex SELECT statements, it is cumbersome and >> confusing to write everything in a single line, and

Re: [SQL] \copy multiline

2012-11-29 Thread Rob Sargentg
On 11/29/2012 02:33 AM, Guillaume Lelarge wrote: On Wed, 2012-11-28 at 21:21 -0600, Seb wrote: Hi, I use \copy to output tables into CSV files: \copy (SELECT ...) TO 'a.csv' CSV but for long and complex SELECT statements, it is cumbersome and confusing to write everything in a single line, an

Re: [SQL] unique keys / foreign keys on two tables

2012-11-29 Thread Wolfe Whalen
Hi Gary, The most straightforward way to ensure that the two tables have unique IDs would be to create one sequence called something like "destination_seq" and have the id column in both tables default to NEXTVAL('destination_seq'). As far as storing the destinations go, I'm guessing that you're

[SQL] unique keys / foreign keys on two tables

2012-11-29 Thread Gary Stainburn
I'm designing the schema to store a config from our switchboards. As with all PBX's the key is the dialed number which is either an extension number or a group (hunt/ring/pickup) number. I have two tables, one for extensions and one for groups, basically ext_id int4 primary key ext_desc

Re: [SQL] \copy multiline

2012-11-29 Thread Guillaume Lelarge
On Wed, 2012-11-28 at 21:21 -0600, Seb wrote: > Hi, > > I use \copy to output tables into CSV files: > > \copy (SELECT ...) TO 'a.csv' CSV > > but for long and complex SELECT statements, it is cumbersome and > confusing to write everything in a single line, and multiline statements > don't seem