Re: stored procs

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: stored procs
Date: 2011-09-30 08:45:14
Message-ID: 4E85819A.6070607@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 09/30/11 1:28 AM, John R Pierce wrote:
> On 09/30/11 1:23 AM, John R Pierce wrote:
>> convert the fields to bigint which are 64 bit and not likely to wrap
>> around any time in this century
>
> indeed, this is as simple as ...
>
> alter table tblname alter column id type bigint;
>
> of course, you'll need to alter all the FK fields that refer to it
> too, and I don't know if that entangles this.
>
>

yes, quite easy.

test=# create table xxx (id serial primary key, val text);
NOTICE: CREATE TABLE will create implicit sequence "xxx_id_seq" for
serial column "xxx.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"xxx_pkey" for table "xxx"
CREATE TABLE
test=# create table yyy (id serial primary key, xxx_id int references
xxx(id));
NOTICE: CREATE TABLE will create implicit sequence "yyy_id_seq" for
serial column "yyy.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"yyy_pkey" for table "yyy"
CREATE TABLE

test=# alter table xxx alter column id type bigint;
ALTER TABLE
test=# alter table yyy alter column xxx_id type bigint;
ALTER TABLE

voila!

--
john r pierce N 37, W 122
santa cruz ca mid-left coast

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gregg Jaskiewicz 2011-09-30 09:18:09 Re: Rules going away
Previous Message John R Pierce 2011-09-30 08:28:27 Re: stored procs