Summary of using the describe command in MySQL,
1. The describe command is used to view detailed design information of a specific table.
For example, to view the design information of the guestbook table:
describe guestbookdescribe ol_user userid
2. You can use "show comnus" to view the column names of tables in the database.
There are two ways to use:
Show columns form table name from database name
Or:
Show columns from database name. Table Name
3. Use the describe command to query the information of a specific column
describe guestbook id
Query the column information of the id field in guestbook.
{DESCRIBE | DESC} tbl_name [col_name | wild]
DESCRIBE is the abbreviation of show columns from.
DESCRIBE provides column information about a table. Col_name can be a column name or a string containing the SQL wildcard characters "%" and. There is no need to enclose strings in quotation marks.
mysql> desc ol_user username\G
*************************** 1. row *************************** Field: UserName Type: varchar(100) Null: NO Key: MULDefault: Extra:1 row in set (0.02 sec)
Iv. Determine whether a field exists
mysql_connect('localhost', 'root', 'root');mysql_select_db('demo');$test = mysql_query('Describe cdb_posts first');$test = mysql_fetch_array($test);
$ Test [0] returns the name of this field. For example, if you want to query the first field, the first field is returned.
If this field does not exist, NULL is returned. You can determine whether a field exists.