Re: [SQL] changing a column's position in table, how do you do that

2005-09-27 Thread Chris Browne
[EMAIL PROTECTED] (Ferindo Middleton Jr) writes: > Is there a way to change the position attribute of a column in a > table? I have data that I need to import into various tables in my db > on a consistent basis... I usually us e the COPY ... FROM query but I > can't control the -order- of the fiel

Re: [SQL] changing a column's position in table, how do you do that

2005-09-27 Thread Stewart Ben (RBAU/EQS4) *
Ferindo, > Is there a way to change the position attribute of a column > in a table? AFAIK, there's no way to change this easily. The best way to do it would be as follows: BEGIN WORK; LOCK TABLE mytable IN ACCESS EXCLUSIVE MODE; ALTER TABLE mytable ADD COLUMN col_to_move_2 coltype; UPDATE myt

[SQL] changing a column's position in table, how do you do that

2005-09-27 Thread Ferindo Middleton Jr
Is there a way to change the position attribute of a column in a table? I have data that I need to import into various tables in my db on a consistent basis... I usually us e the COPY ... FROM query but I can't control the -order- of the fields my client dumps the data so I would like to be abl

Re: [SQL] how to do 'deep queries'?

2005-09-27 Thread Anthony Molinaro
> Well, perhaps you will one day and a developer will hose your server > with a "accidental" cross join and then you will understand. Hehe :)) hey man, that's what testing and code review is all about (dev teams still do that don't they?) Accidental cartesians don't get to production ;) Regar

Re: [SQL] how to do 'deep queries'?

2005-09-27 Thread Daryl Richter
Anthony Molinaro wrote: > Daryl, > > >>Whether you feel that is unnecessary or not, it *is* the ANSI Standard > > >>and is thus, by definition, "how queries should be written." > > > I disagree 100%. Oracle and db2 introduced window functions years > before > Ansi added them. Should we not have u

Re: [SQL] Why doesn't the SERIAL data type automatically have a

2005-09-27 Thread Scott Marlowe
On Mon, 2005-09-26 at 20:03, Tom Lane wrote: > Ferindo Middleton Jr <[EMAIL PROTECTED]> writes: > > Is there some reason why the SERIAL data type doesn't automatically have > > a UNIQUE CONSTRAINT. > > It used to, and then we decoupled it. I don't think "I have no use for > one without the other

Re: [SQL] Updating cidr column with network operator

2005-09-27 Thread Axel Rau
Am 27.09.2005 um 17:02 schrieb Daryl Richter: Ok, I guess, but isn't tit true now that you can insert a new address row which doesn't belong to any valid network?? Yes, I can. But in the earlier approach, the fk pointed at a special row in network ("UNKNOWN"), which maks no big difference. I

Re: [SQL] Updating cidr column with network operator

2005-09-27 Thread Daryl Richter
[EMAIL PROTECTED] wrote: Am 27.09.2005 um 16:02 schrieb Daryl Richter: An attribute is redundant if it repeats a fact that can be learned without it. If one table contains IP addresses and another contains networks, then you can associate IP addresses and networks with a join of the two

Re: [SQL] Updating cidr column with network operator

2005-09-27 Thread Axel Rau
Am 27.09.2005 um 16:02 schrieb Daryl Richter: > An attribute is redundant if it repeats a fact that can be learned > without it. If one table contains IP addresses and another contains > networks, then you can associate IP addresses and networks with a > join of the two tables; indeed, this is h

Re: [SQL] how to do 'deep queries'?

2005-09-27 Thread Anthony Molinaro
Daryl, > Whether you feel that is unnecessary or not, it *is* the ANSI Standard > and is thus, by definition, "how queries should be written." I disagree 100%. Oracle and db2 introduced window functions years before Ansi added them. Should we not have used them? It absurd to avoid using a

Re: [SQL] add column if doesn't exist

2005-09-27 Thread Chris Browne
[EMAIL PROTECTED] ("Brandon Metcalf") writes: > p == [EMAIL PROTECTED] writes: > > p> Brandon Metcalf wrote: > p> > Is there a way to check for the existence of a column in a table > p> > other than, say, doing a SELECT on that column name and checking the > p> > output? > > p> SELECT * FROM

Re: [SQL] Updating cidr column with network operator

2005-09-27 Thread Daryl Richter
Michael Fuhr wrote: > On Mon, Sep 26, 2005 at 12:34:59PM +0200, Axel Rau wrote: > >>Am 26.09.2005 um 02:05 schrieb Michael Fuhr: >> >>>On Fri, Sep 23, 2005 at 09:19:25PM +0200, Axel Rau wrote: >>> I'm sure this would be the cleanest solution but remember networks change. >>> >>>Yes, which

Re: [SQL] how to do 'deep queries'?

2005-09-27 Thread Daryl Richter
Anthony Molinaro wrote: that query is 100% correct. it's just an equijoin (a type of inner join) between 3 tables. the syntax you show is how queries should be written and is more representative of what a joins between relations really are: Cartesian products with filters applied the ansi

Re: [SQL] add column if doesn't exist

2005-09-27 Thread Brandon Metcalf
p == [EMAIL PROTECTED] writes: p> Brandon Metcalf wrote: p> > Is there a way to check for the existence of a column in a table p> > other than, say, doing a SELECT on that column name and checking the p> > output? p> SELECT * FROM information_schema.columns; p> Customize to taste. Yes, t