pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Owen Jacobson <ojacobson@osl.com>
Cc: Maciej Piekielniak <piechcio@isb.com.pl>
Cc: pgsql-sql@postgresql.org
Subject: Re: alter table
Date: Wed, 15 Feb 2006 12:03:26 -0800 (PST)
Message-ID: <20060215120109.S99569@megazone.bigpanda.com> (raw)
In-Reply-To: <144D12D7DD4EC04F99241498BB4EEDCC2207B6@nelson.osl.com>
References: <144D12D7DD4EC04F99241498BB4EEDCC2207B6@nelson.osl.com>

On Wed, 15 Feb 2006, Owen Jacobson wrote:

> Maciej Piekielniak wrote:
> >
> > Wednesday, February 15, 2006, 8:31:17 PM, you wrote:
> > OJ> Note that prior to 8.0 PostgreSQL does not support
> > multiple ALTER actions in a single query.  To get an
> > equivalent effect, wrap separate ALTER TABLE queries in a transaction:
> >
> > OJ> BEGIN;
> > OJ> alter table xyz alter column id set default nextval('xyz_seq');
> > OJ> alter table xyz alter column foo set default '';
> > OJ> COMMIT;
> > OJ> Also, are you sure you want '' as a column default, and
> > not ALTER COLUMN foo DROP DEFAULT?
> > OJ> -Owen
> >
> > OK. THX. Second question:
> >
> > First, maybe set many fields with the same action - ex. set default?
> >
> > Ex. on mysql
> >
> > ALTER TABLE proc MODIFY name char(64) DEFAULT '' NOT NULL,
> >                  MODIFY specific_name char(64) DEFAULT '' NOT NULL,
> >                  MODIFY sql_data_access
> >                         enum('CONTAINS_SQL',
> >                              'NO_SQL',
> >                              'READS_SQL_DATA',
> >                              'MODIFIES_SQL_DATA'
> >                             ) DEFAULT 'CONTAINS_SQL' NOT NULL....
>
> Under PostgreSQL 7.4 you'd need to do those as three separate ALTER TABLE statements:
>
> BEGIN;
> ALTER TABLE proc ALTER name DEFAULT '' NOT NULL;
> ALTER TABLE proc ALTER specific_name DEFAULT '' NOT NULL;
> ... and so on ...
> COMMIT;
>
> Note that ALTER TABLE under postgresql cannot change a column's type
> (including precision or length).

Not in 7.4, but I believe 8.1 allows that (ALTER TABLE ALTER COLUMN TYPE
with semi-optional USING)



view thread (22+ messages)  latest in thread

Message-ID: <20060215120109.S99569@megazone.bigpanda.com>
Permalink:  ../20060215120109.S99569@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20060215120109.S99569@megazone.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, ojacobson@osl.com, piechcio@isb.com.pl
  Subject: Re: alter table
  In-Reply-To: <20060215120109.S99569@megazone.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox