Re: Q: Truncated output - Mailing list pgsql-general

From Ross J. Reedstrom
Subject Re: Q: Truncated output
Date
Msg-id 20000601173219.A23474@rice.edu
Whole thread Raw
In response to Q: Truncated output  (efinley@efinley.com (Elliot Finley))
List pgsql-general
On Thu, Jun 01, 2000 at 08:51:13PM +0000, Elliot Finley wrote:
> I've just started using Postgres 6.5.2 and I'm trying to figure out a
> way to be able to see the complete 'type' for the 'employee_id' field.
> I can't remember which sequence I used in the 'nextval', so I need to
> be able to see which one is being used there.
>
> shift=> \d employee
> Table    = employee
> +------------------------------+----------------------------------+-------+
> |              Field           |              Type                | Length|
> +------------------------------+----------------------------------+-------+
> | employee_id                  | int4 not null default nextval (  |     4 |

Yeah, this is ugly. If you start up psql with the -E switch, you'll see the
queries the psql uses to get the info. Something like this will get what
you want:

select adsrc from pg_class c, pg_attribute,  pg_attrdef  where
adrelid=c.oid and attrelid=c.oid and attnum=adnum and relname ='employee'
and attname= 'employee_id';

Oh, a hint: if you used the 'serial' type to create the id, the sequence
is named <tablename>_<fieldname>_seq, unless it's to long, then it gets
truncated (fieldname first, then tablename)

Ross
--
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St.,  Houston, TX 77005

pgsql-general by date:

Previous
From: leonbloy@sinectis.com.ar
Date:
Subject: Re: btree index and max()
Next
From: Tom Lane
Date:
Subject: Re: Postmaster won't -HUP