Re: [HACKERS] ALTER TABLE RENAME column

2006-11-17 Thread Richard Huxton

Peter Eisentraut wrote:

Jim Nasby wrote:

Any reason not to support renaming columns? Can this be added to
TODO?


Upgrade to Postgres95.


Hey, is Jim running MySQL 5?

--
  Richard Huxton
  Archonet Ltd

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
  choose an index scan if your joining column's datatypes do not
  match


Re: [HACKERS] ALTER TABLE RENAME column

2006-11-17 Thread Jonah H. Harris

On 11/16/06, Jim Nasby [EMAIL PROTECTED] wrote:

Any reason not to support renaming columns? Can this be added to TODO?


ALTER TABLE yo_table RENAME COLUMN yo_column TO yo_new_column;

?

--
Jonah H. Harris, Software Architect | phone: 732.331.1300
EnterpriseDB Corporation| fax: 732.331.1301
33 Wood Ave S, 2nd Floor| [EMAIL PROTECTED]
Iselin, New Jersey 08830| http://www.enterprisedb.com/

---(end of broadcast)---
TIP 7: You can help support the PostgreSQL project by donating at

   http://www.postgresql.org/about/donate


Re: [HACKERS] ALTER TABLE RENAME column

2006-11-17 Thread Andrew Dunstan

Jonah H. Harris wrote:

On 11/16/06, Jim Nasby [EMAIL PROTECTED] wrote:

Any reason not to support renaming columns? Can this be added to TODO?


ALTER TABLE yo_table RENAME COLUMN yo_column TO yo_new_column;




Maybe Jim actually wants a reason to remove support for this ... :-)

cheers

andrew

---(end of broadcast)---
TIP 6: explain analyze is your friend


Re: [HACKERS] ALTER TABLE RENAME column

2006-11-17 Thread Mario Weilguni
 Uh, we did that years ago.

Really? 
+ o Add ALTER TABLE RENAME COLUMN (should rename appropriate sequences and 
constraints)

Sounds like this is not done, at least not renaming sequencens and constraints, 
or am I wrong here?

Regard
Mario Weilguni

-Ursprüngliche Nachricht-
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Tom Lane
Gesendet: Freitag, 17. November 2006 07:05
An: Jim Nasby
Cc: PostgreSQL Hackers
Betreff: Re: [HACKERS] ALTER TABLE RENAME column 

Jim Nasby [EMAIL PROTECTED] writes:
 Any reason not to support renaming columns? Can this be added to TODO?

Uh, we did that years ago.

regards, tom lane

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [HACKERS] ALTER TABLE RENAME column

2006-11-17 Thread Jonah H. Harris

On 11/17/06, Mario Weilguni [EMAIL PROTECTED] wrote:

Sounds like this is not done, at least not renaming sequencens and constraints, 
or am I wrong here?


To rename a sequence or a table:

ALTER TABLE yo_table RENAME TO yo_new_table;
ALTER TABLE yo_sequence RENAME TO yo_new_sequence;

Or am I mistaken?

--
Jonah H. Harris, Software Architect | phone: 732.331.1300
EnterpriseDB Corporation| fax: 732.331.1301
33 Wood Ave S, 2nd Floor| [EMAIL PROTECTED]
Iselin, New Jersey 08830| http://www.enterprisedb.com/

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

  http://www.postgresql.org/docs/faq


Re: [HACKERS] ALTER TABLE RENAME column

2006-11-17 Thread Jonah H. Harris

On 11/17/06, Mario Weilguni [EMAIL PROTECTED] wrote:

+ o Add ALTER TABLE RENAME COLUMN (should rename appropriate sequences and 
constraints)


Actually, I don't believe it cascades the rename automagically... if
that's what you're asking.

--
Jonah H. Harris, Software Architect | phone: 732.331.1300
EnterpriseDB Corporation| fax: 732.331.1301
33 Wood Ave S, 2nd Floor| [EMAIL PROTECTED]
Iselin, New Jersey 08830| http://www.enterprisedb.com/

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [HACKERS] ALTER TABLE RENAME column

2006-11-17 Thread Mario Weilguni
Right, but I think jim means automatical renames of sequences, and especially 
something like this:
db=# CREATE TABLE foo (bar serial);
NOTICE:  CREATE TABLE will create implicit sequence foo_bar_seq for serial 
column foo.bar
CREATE TABLE
db=# ALTER TABLE foo rename bar to baf;
ALTER TABLE
db=# \d foo
  Table public.foo
 Column |  Type   | Modifiers
+-+---
 baf| integer | not null default nextval('foo_bar_seq'::regclass)

The sequence still is named foo_bar_seq.

IMO this should do:
Alter sequence foo_bar_seq rename to foo_baf_seq;
Alter table foo alter baf set default nextval('foo_baf_seq')



-Ursprüngliche Nachricht-
Von: Jonah H. Harris [mailto:[EMAIL PROTECTED] 
Gesendet: Freitag, 17. November 2006 16:27
An: Mario Weilguni
Cc: Tom Lane; Jim Nasby; PostgreSQL Hackers
Betreff: Re: [HACKERS] ALTER TABLE RENAME column

On 11/17/06, Mario Weilguni [EMAIL PROTECTED] wrote:
 Sounds like this is not done, at least not renaming sequencens and 
 constraints, or am I wrong here?

To rename a sequence or a table:

ALTER TABLE yo_table RENAME TO yo_new_table; ALTER TABLE yo_sequence RENAME TO 
yo_new_sequence;

Or am I mistaken?

--
Jonah H. Harris, Software Architect | phone: 732.331.1300
EnterpriseDB Corporation| fax: 732.331.1301
33 Wood Ave S, 2nd Floor| [EMAIL PROTECTED]
Iselin, New Jersey 08830| http://www.enterprisedb.com/

---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org


Re: [HACKERS] ALTER TABLE RENAME column

2006-11-17 Thread Tom Lane
Mario Weilguni [EMAIL PROTECTED] writes:
 IMO this should do:
 Alter sequence foo_bar_seq rename to foo_baf_seq;
 Alter table foo alter baf set default nextval('foo_baf_seq')

No, it should not, because that risks breaking other references to the
sequence (eg, in user-written functions).  If the user is feeling that
he wants consistency, he can rename the sequence himself and take
responsibility for any side-effects on his code.

regards, tom lane

---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org


Re: [HACKERS] ALTER TABLE RENAME column

2006-11-17 Thread Jonah H. Harris

On 11/17/06, Tom Lane [EMAIL PROTECTED] wrote:

No, it should not, because that risks breaking other references to the
sequence (eg, in user-written functions).  If the user is feeling that
he wants consistency, he can rename the sequence himself and take
responsibility for any side-effects on his code.


I concur.

--
Jonah H. Harris, Software Architect | phone: 732.331.1300
EnterpriseDB Corporation| fax: 732.331.1301
33 Wood Ave S, 2nd Floor| [EMAIL PROTECTED]
Iselin, New Jersey 08830| http://www.enterprisedb.com/

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


[HACKERS] ALTER TABLE RENAME column

2006-11-16 Thread Jim Nasby

Any reason not to support renaming columns? Can this be added to TODO?


patch
Description: Binary data

--
Jim Nasby[EMAIL PROTECTED]
EnterpriseDB  http://enterprisedb.com  512.569.9461 (cell)



---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [HACKERS] ALTER TABLE RENAME column

2006-11-16 Thread Tom Lane
Jim Nasby [EMAIL PROTECTED] writes:
 Any reason not to support renaming columns? Can this be added to TODO?

Uh, we did that years ago.

regards, tom lane

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [HACKERS] ALTER TABLE RENAME column

2006-11-16 Thread Peter Eisentraut
Jim Nasby wrote:
 Any reason not to support renaming columns? Can this be added to
 TODO?

Upgrade to Postgres95.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster