alter table

Started by Vince Vielhaberover 26 years ago4 messages
#1Vince Vielhaber
vev@michvhf.com

Can a serial type be added to an existing table using ALTER TABLE? If so
why doesn't it work on hub? If not, I guess that explains why it doesn't
work, so I'm open to suggestions on how to add it easily...

Vince.
--
==========================================================================
Vince Vielhaber -- KA8CSH email: vev@michvhf.com flame-mail: /dev/null
# include <std/disclaimers.h> TEAM-OS2
Online Campground Directory http://www.camping-usa.com
Online Giftshop Superstore http://www.cloudninegifts.com
==========================================================================

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Vince Vielhaber (#1)
Re: [HACKERS] alter table

Vince Vielhaber <vev@michvhf.com> writes:

Can a serial type be added to an existing table using ALTER TABLE? If so
why doesn't it work on hub? If not, I guess that explains why it doesn't
work, so I'm open to suggestions on how to add it easily...

I'm not sure about this, but I seem to recall that ALTER TABLE ADD
COLUMN doesn't know anything about adding constraints or defaults.
And, of course, the default clause for a serial column is what *really*
makes it go. Given this lack, the fact that ALTER TABLE is also
unprepared to create the underlying sequence object for a SERIAL column
is the least of your worries ;-)

There was some discussion a few months ago about redesigning the support
for SERIAL columns to make them less of an add-on kluge and more of a
real integrated feature. I'd be inclined to think that that should
happen before we try to teach ALTER TABLE about serial columns ---
otherwise it'll just be another kluge in need of replacement. Does
anyone recall what happened with that discussion thread?

regards, tom lane

#3Vince Vielhaber
vev@michvhf.com
In reply to: Tom Lane (#2)
Re: [HACKERS] alter table

On 06-Jul-99 Tom Lane wrote:

Vince Vielhaber <vev@michvhf.com> writes:

Can a serial type be added to an existing table using ALTER TABLE? If so
why doesn't it work on hub? If not, I guess that explains why it doesn't
work, so I'm open to suggestions on how to add it easily...

I'm not sure about this, but I seem to recall that ALTER TABLE ADD
COLUMN doesn't know anything about adding constraints or defaults.
And, of course, the default clause for a serial column is what *really*
makes it go. Given this lack, the fact that ALTER TABLE is also
unprepared to create the underlying sequence object for a SERIAL column
is the least of your worries ;-)

There was some discussion a few months ago about redesigning the support
for SERIAL columns to make them less of an add-on kluge and more of a
real integrated feature. I'd be inclined to think that that should
happen before we try to teach ALTER TABLE about serial columns ---
otherwise it'll just be another kluge in need of replacement. Does
anyone recall what happened with that discussion thread?

regards, tom lane

Now that you mention it I vaguely recall that thread. I'm also thinking
there may be a problem with serial types on hub. I tried using an insert
with select and although it inserted all 106 records, it didn't have a
clue as to what the serial column was. So I dropped the table, dropped
the sequence and created it again. It gives me this:

ERROR: attribute 'mirrorid' not found

I dropped Marc a note about it since I'm about to run out the door. (Baseball
playoffs are here)

Vince.
--
==========================================================================
Vince Vielhaber -- KA8CSH email: vev@michvhf.com flame-mail: /dev/null
# include <std/disclaimers.h> TEAM-OS2
Online Campground Directory http://www.camping-usa.com
Online Giftshop Superstore http://www.cloudninegifts.com
==========================================================================

#4Ryan Bradetich
rbrad@hpb50023.boi.hp.com
In reply to: Vince Vielhaber (#3)
Re: [HACKERS] alter table

Vince Vielhaber <vev@michvhf.com> writes:

Can a serial type be added to an existing table using ALTER TABLE? If so
why doesn't it work on hub? If not, I guess that explains why it doesn't
work, so I'm open to suggestions on how to add it easily...

I'm not sure about this, but I seem to recall that ALTER TABLE ADD
COLUMN doesn't know anything about adding constraints or defaults.
And, of course, the default clause for a serial column is what *really*
makes it go. Given this lack, the fact that ALTER TABLE is also
unprepared to create the underlying sequence object for a SERIAL column
is the least of your worries ;-)

There was some discussion a few months ago about redesigning the support
for SERIAL columns to make them less of an add-on kluge and more of a
real integrated feature. I'd be inclined to think that that should
happen before we try to teach ALTER TABLE about serial columns ---
otherwise it'll just be another kluge in need of replacement. Does
anyone recall what happened with that discussion thread?

regards, tom lane

Yes, I was the one who wanted to redo SERIAL support as a type instead of a
sequence and index. I hope to begin working on that later this week, or
sometime next week. (Work has kept me busy lately :()

-Ryan