From: | Chris <csmith(at)squiz(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: nextval, sequences and sequencenames |
Date: | 2001-08-15 02:14:02 |
Message-ID: | 5.1.0.14.0.20010815120743.0327b010@cooee.cybersydney.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-novice |
Hi,
> > My question:
> > is there anyway of retreiving the sequence_name corresponding to the
> > respective column,
> > knowing just the tablename and columnname?
> >
> > The reason I need to do this, is because the application I write
> > dynamicly creates new tables, and I have no way of knowing the sequence
> > name before hand.
> >
>
>If it is very difficult finding that sequence name (I'm not sure)
>You may want to create the sequence yourself instead of using SERIAL.
>Then you would know the name.
Not hard at all.
csmith=# create table test (testid serial, name text);
NOTICE: CREATE TABLE will create implicit sequence 'test_testid_seq' for
SERIAL column 'test.testid'
NOTICE: CREATE TABLE/UNIQUE will create implicit index 'test_testid_key'
for table 'test'
CREATE
Sequence name becomes <tablename>_<columnname>_seq
so if we use the serial datatype to create a column called "xyz" in the
table "abc" the sequence name is :
abc_xyz_seq
Make sense?
-----------------
Chris Smith
http://www.squiz.net/
From | Date | Subject | |
---|---|---|---|
Next Message | Justin Clift | 2001-08-15 02:22:20 | Re: OpenLDAP - Postgresql HOWTO |
Previous Message | Lee Harr | 2001-08-15 02:02:03 | Re: nextval, sequences and sequencenames |
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2001-08-15 08:04:43 | Re: Re: nextval, sequences and sequencenames |
Previous Message | Lee Harr | 2001-08-15 02:02:03 | Re: nextval, sequences and sequencenames |