472,325 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,325 software developers and data experts.

Could my postgres database be corrupted?

Hi,

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!

----------------snip------------------
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(# len INTERVAL HOUR TO MINUTE,
eve(# CONSTRAINT code_title PRIMARY KEY(code,title)
eve(# );
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
'code_title' for
table 'films'
CREATE TABLE
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 1251

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Adam Kempa | last post by:
Hello I've been installed Postgres 7.4.2 on FreeBSD system and when load average grow up i've error in postgres like this: ERROR: permission...
1
by: Richard Bailey | last post by:
Greetings. Today I was testing the sql backup/restore functions on our primary server. I was able to backup my database without any problems but...
0
by: news.paradise.net.nz | last post by:
My database appears to be a little corrupted, so far it's running along 99% ok, but i am getting some strange results. Primarily i can't back it up...
3
by: N.K. | last post by:
Hi, I've just installed postgres on the Linux server. It is supposed to start automatically which I think it does since I can run an sql stmt right...
7
by: Abdul-Wahid Paterson | last post by:
Hi, I have had a site working for the last 2 years and have had no problems until at the weekend I replace my database server with a newer one....
0
by: Jesse | last post by:
Hi all, I need some help with Access database and Postgres Database i am trying to link some Acces tables to Postgres tabels but id doesn't seem...
0
by: Ann Harrison | last post by:
Tom, Actually, I've never had a corrupted firebird database. There were two bugs in an older version of InterBase that produced income for me....
3
by: Bernhard Ankenbrand | last post by:
Hi, we have a table width about 60.000.000 entrys and about 4GB storage size. When creating an index on this table the whole linux box freezes...
7
by: Randy Yates | last post by:
This has probably been asked before so please be gracious. I have looked on the postgres site and didn't find anything "satisfying." Is there...
0
by: NM | last post by:
Hello, I've got a problem inserting binary objects into the postgres database. I have binary objects (e.g. images or smth else) of any size which...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.