Finding Composite Keys in Informix?
Posted in 1997
Topics: General Discussion
I have an undocumented database I am trying to reverse-engineer. In
particular I want to find potential candidate keys. Typically I use the
following syntax (for keys consisting of a single column):
If select count(*) from t; = select count(distinct c) from t; then c is
a potential candidate key for table t.
To search for potential composite candidate keys I try:
select count(distinct c1, c2) from t;
This works with a number of other DBMS where the semantics of the query
is to count the number of distinct (c1,c2) pairs. Informix, however,
gives me a syntax error. When I omit the count aggregate, however, it
works as expected.
select distinct c1, c2 from t;
Is there something wrong with the way I am trying to find potential
composite candidate keys? Is there another way to do this in SQL?
Thanks for any help,
--
Robert Winkler
U.S. Army Research Laboratory
Beckman Institute, Room 4357
405 North Matthews Ave, Urbana, IL 61801