[NCLUG] Annoying post-meeting SQL curiosities

Bob Proulx bob at proulx.com
Fri Dec 12 16:02:37 MST 2008


Sean Reifschneider wrote:
> I'm not sure I understand where Bob gets off calling it a primary key
> though.

Oops.  You are right.  Looking back I can see that I was slightly
confused.  I saw this:

    CREATE TABLE test (a INTEGER);
    CREATE UNIQUE INDEX test_a_idx ON test (a);

And my mind read this:

  CREATE TABLE test (a INTEGER, PRIMARY KEY (a));

That is why I was calling it the primary key.  I had read the example
incorrectly.  But both enforces a uniqueness upon a column.  In one
case it is by the primary key and in the other it is by the unique
index.  I think the resulting behavior is almost the the same in this
case.

Bob



More information about the NCLUG mailing list