• leslaw (2/10/2009)


    All tables should have primary key, so it should also be created.

    Leslaw

    Cardinal Moden will call me a heretic, yet I beg to differ with respect to the word "ALL".

    I agree that any non-temporary table should have a unique primary key, but oftentimes a temporary table is built within a stored procedure and then returned with a final select statement. These tables do not survive the ending of the stored procedure. By the time you see the results, the table itself no longer exists.

    Sometimes the logic of the stored procedure involves a need to go back and retrieve or update values of particular rows within that table, and in such cases an index is definitely a good idea. But, in the absence of any need to go back and retrieve or update the results from a particular row, what purpose is served by imposing an arbitrary primary key?

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills