Describing a Table

When you aren’t logged into the MySQL command line, here’s a handy piece of code that you can use to verify that a table has been correctly created from inside a browser. It simply issues the query DESCRIBE devices and then outputs an HTML table with four headings—Column, Type, Null, and Key—underneath which all columns. Within the table are shown. To use it with other tables, simply replace the name devices in the query with that of the new table.

Describing the devices table

The output from the program should look like this:
Column Type Null Key
id smallint(6) NO PRI
family varchar(32) NO
name varchar(32) NO
age tinyint(4) NO

Leave a Reply

Your email address will not be published. Required fields are marked *