473,322 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

List prime key column names

CN
Hi!

I am trying to retrieve the column names that comprise primary key of a
table.
According to manual, pg_index.indkey is an array of indnatts whose usage
I am unaware of.

CREATE TABLE table1 (
PRIMARY KEY (c1,c2),
c1 SMALLINT,
c2 VARCHAR(10),
c3 VARCHAR(10)
)WITHOUT OIDS;

I need a SQL to list the following 2 rows:

c1
c2

The following SQL fails with error "syntax error at or near "ANY" at
character 214":

select attname
from pg_class,pg_index,pg_attribute
where relname='table1' and relkind='r' and relhaspkey
and indrelid=pg_class.oid and indisprimary
and attrelid=pg_class.oid and attnum ANY (indkey)

Helps will be much appreciated!

Regards,
CN

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #1
0 1104

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

Similar topics

8
by: Matt Fletcher | last post by:
Hi guys, I am trying to allow the models in a mysql database to be ordered by the site owner. I was thinking along the lines of a <SELECT> list containing the model names and Up and Down...
7
by: Ben | last post by:
Hi In a list I have a number of soccer players. Each player has a different rating for attacking, defending, midfield fitness and goalkeeping. I have devised a while loop that goes through...
8
by: tom | last post by:
I am new to SQL administration. >From a list of IDs that are the primary key in one table (i.e. Customer Table), I want to make changes in tables that use those IDs as a foreign key. ...
7
by: brian.digipimp | last post by:
Write a program that prompts the user to input a positive integer. It should then output a message indicating whether the number is a prime number. (Note: An even number is prime if it is 2. An odd...
1
by: Melissa Kay Beeline | last post by:
OK, here's the sitch : we have an access control system at work that registers ever entry/exit of every employee. I recently made some queries in Access so the ppl in HR could make reports (who...
0
by: CN | last post by:
Hi! I am trying to retrieve the column names that comprise primary key of a table. According to manual, pg_index.indkey is an array of indnatts whose usage I am unaware of. CREATE TABLE...
10
by: randomtalk | last post by:
hello, i have another problem i feel that i have to be missing something.. Basically, i've written a recursive function to find all the prime up to a number (lim).. here is the function: The...
1
by: vekka | last post by:
Hi! Programming language: C I wondered if any of you are able to see what is wrong with my code. What I want to do is to find the union of a set of numbers. I use a singly linked list. and my union...
5
by: JvC | last post by:
Background Access 2003. MDB Front End. I am populating a list box with the names of queries in the system. I am searching for strings in the query names and then creating a value list for users...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.