• codebyo (6/27/2012)


    Duncan Pryde (6/27/2012)


    You can't define indexes explicitly (i.e. by CREATE INDEX) in a CREATE TABLE statement. As far as I know the only way to create indexes in CREATE TABLE statements is to have them created by defining primary keys or unique constraints.

    Yes, but a UNIQUE constraint automagically adds an index so answer #2 could be a possbility. Or am I missing something here?

    Thank you for the question, Hugo.

    I love this kind of questions that makes you think twice, thrice.

    Now I need some strong coffee. 😀

    No, I thought the same too, but decided that it would be too much of a trick question if that were the answer. 😉 Also, Mike's question seemed to be about whether the fact that there was a foreign key constraint on the column meant that no index could be created.

    I think the question was designed partly to check people didn't think that creating a foreign key also created an index - which is not an uncommon misconception.