title: Information schema and Primary Keys
body: <p>How do I just print out a 'primary key' for the column with the primary key? </p>
  
  <p>I get 'primary key' for all the columns if the table has a primary key, instead of the one column with the primary key and the other columns as blank in keyType.</p>
  
  <pre><code>   SELECT c.TABLE_NAME, 
            c.COLUMN_NAME, 
            c.DATA_TYPE, 
            c.Column_default, 
            c.character_maximum_length, 
            c.numeric_precision, 
            c.is_nullable,
            CASE 
              WHEN u.CONSTRAINT_TYPE = 'PRIMARY KEY' THEN 'primary key'
              ELSE '' 
            END AS KeyType
       FROM INFORMATION_SCHEMA.COLUMNS as c
  LEFT JOIN information_schema.table_constraints as u ON c.table_name = u.table_name
   ORDER BY table_name
  </code></pre>