Re: stored procs - Mailing list pgsql-general

From John R Pierce
Subject Re: stored procs
Date
Msg-id 4E85819A.6070607@hogranch.com
Whole thread Raw
In response to Re: stored procs  (John R Pierce <pierce@hogranch.com>)
Responses Re: stored procs  ("J.V." <jvsrvcs@gmail.com>)
List 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


pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: stored procs
Next
From: Gregg Jaskiewicz
Date:
Subject: Re: Rules going away