Re: Q: Truncated output

From: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Q: Truncated output
Date: 2000-06-01 22:32:19
Message-ID: 20000601173219.A23474@rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)rice(dot)edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2000-06-01 22:57:37 Re: Postmaster won't -HUP
Previous Message Michael Meskes 2000-06-01 22:17:05 Re: PostgreSQL article in LinuxWorld