This article describes how to use the describe command in MySQL. The describe command is mainly used to obtain information about tables or columns. For more information, see
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.
The above is the usage of the describe command in MySQL _ MySQL content. For more information, see PHP Chinese network (www.php1.cn )!