Q: Truncated output
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 |
| employer_id | int4 not null default 0 | 4 |
| trading_unit_id | int4 not null default 0 | 4 |
| username | text not null default '' | var |
| password | text not null default '' | var |
| first_name | text not null default '' | var |
| last_name | text not null default '' | var |
| address1 | text not null default '' | var |
| address2 | text not null default '' | var |
| city | text not null default '' | var |
| state | text not null default '' | var |
| zip | int4 not null default 0 | 4 |
| email | text not null default '' | var |
+----------------------------------+----------------------------------+-------+
Index: employee_pkey
--
Elliot (efinley@efinley.com) Weird Science!
A quick and dirty trick, is to make a dump of the schema
of the database (or the table):
postgres# pg_dump -s [-t employee] <my-db-name> > db.dump.schema
Regards
Hernan Gonzalez
Buenos Aires, Argentina
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
|
| employer_id | int4 not null default 0 | 4
|
| trading_unit_id | int4 not null default 0 | 4
|
| username | text not null default '' | var
|
| password | text not null default '' | var
|
| first_name | text not null default '' | var
|
| last_name | text not null default '' | var
|
| address1 | text not null default '' | var
|
| address2 | text not null default '' | var
|
| city | text not null default '' | var
|
| state | text not null default '' | var
|
| zip | int4 not null default 0 | 4
|
| email | text not null default '' | var
|
+----------------------------------+----------------------------------+-------+
Show quoted text
Index: employee_pkey--
Elliot (efinley@efinley.com) Weird Science!
Import Notes
Resolved by subject fallback
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