Summary of using the describe command in MySQL,

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.