SQLzoo.net

How can you determine the primary key using SQL?

MySQL
If you have access to the SQL code which created the table the primary key can be seen easily. The primary key may be specified in one of two ways:
CREATE TABLE cia (name VARCHAR(10) PRIMARY KEY,
                  population INTEGER)
or, where the primary key is composite:
CREATE TABLE casting(movieid INTEGER,
                     actorid INTEGER,
                     PRIMARY KEY (movieid, actorid)
                     )
If this is not possible then implementation specific commands may work.


Specific to MySQL
none

Related links:

  • META DATA