470,614 Members | 1,505 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,614 developers. It's quick & easy.

Could my postgres database be corrupted?


I wanted to get the primary keys' column names and data types for a
particular table created. Although I only created one primary key
involving 2 columns for the table, my select query below return all
the column. Below is the screenshots. I'm on Linux Slackware v9.0.0
kernel v2.4.21.

I'm still quite new with postgreSQL so I'll be grateful if you can
point out a better way to execute this query. The reason I'm doing
this is to create a way to query a underlying table given just its
tablename so that i can dynamically use it in my program.

Thank you!

eve=# CREATE TABLE films (
eve(# code CHAR(5),
eve(# title VARCHAR(40),
eve(# did DECIMAL(3),
eve(# date_prod DATE,
eve(# kind VARCHAR(10),
eve(# CONSTRAINT code_title PRIMARY KEY(code,title)
eve(# );
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
'code_title' for
table 'films'
eve=# SELECT c.attname, d.typname FROM
eve-# pg_class a, pg_constraint b,
eve-# pg_attribute c, pg_type d
eve-# WHERE b.conrelid=a.relfilenode
eve-# AND a.relfilenode=b.conrelid
eve-# AND c.attrelid=a.relfilenode
eve-# AND c.attnum>0
eve-# AND d.typelem=c.atttypid
eve-# AND a.relname='films'
eve-# AND b.contype='p';
attname | typname
code | _bpchar
kind | _varchar
title | _varchar
date_prod | _date
len | _interval
did | _numeric
(6 rows)
Jul 19 '05 #1
0 1207

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Adam Kempa | last post: by
1 post views Thread by Richard Bailey | last post: by
reply views Thread by Jesse | last post: by
reply views Thread by Ann Harrison | last post: by
3 posts views Thread by Bernhard Ankenbrand | last post: by
7 posts views Thread by Randy Yates | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.