Ways to view MySQL table structure and table creation statements

Source: Internet
Author: User
Tags datetime mul

  1. There are three ways to view the MySQL table structure:
  2. 1,DESC tablename;
  3. For example:
  4. To view the Jos_modules table Structure command:
  5. Desc Jos_modules;
  6. View results:
  7. mysql> desc jos_modules;
  8. +------------------+---------------------+------+-----+---------------------+----------------+  
  9. | Field | Type | Null | Key | Default |  Extra |
  10. +------------------+---------------------+------+-----+---------------------+----------------+  
  11. | id                | int (one)               | no   | pri | NULL                 | auto_ increment |  
  12. | title            | text                 |  no   |     | NULL                 |                 |  
  13. | content          | text                 |  no   |     | NULL                 |                 |  
  14. | ordering         | int (11)              | NO    |     | 0                    |                 |  
  15. | Position | varchar (50) |     YES | |                NULL |  |
  16. | Checked_out | Int (one) unsigned |     NO | |                0 |  |
  17. | Checked_out_time | datetime |     NO | |                0000-00-00 00:00:00 |  |
  18. | Published | tinyint (1) | NO | MUL |                0 |  |
  19. | module           | varchar (         | yes | mul)  | null                 |                 |  
  20. | Numnews | Int (11) |     NO | |                0 |  |
  21. | Access | tinyint (3) unsigned |     NO | |                0 |  |
  22. | Showtitle | tinyint (3) unsigned |     NO | |                1 |  |
  23. | params | Text |     NO | |                NULL |  |
  24. | Iscore | Tinyint (4) |     NO | |                0 |  |
  25. | client_id | Tinyint (4) |     NO | |                0 |  |
  26. | Control | Text |     NO | |                NULL |  |
  27. +------------------+---------------------+------+-----+---------------------+----------------+  
  28. 2, show create table tablename;
  29. For example:
  30. To view the Jos_modules table Structure command:
  31. Show create table jos_modules;
  32. View results:
  33. Mysql> Show create table jos_modules;
  34. Jos_modules | CREATE TABLE ' jos_modules ' (
  35. ' ID ' int (one) not NULL auto_increment,
  36. ' title ' text is not NULL,
  37. ' Content ' text is not NULL,
  38. ' Ordering ' int (one) not NULL DEFAULT ' 0 ',
  39. ' Position ' varchar DEFAULT NULL,
  40. ' Checked_out ' int (one) unsigned not NULL DEFAULT ' 0 ',
  41. ' Checked_out_time ' datetime not NULL DEFAULT ' 0000-00-00 00:00:00 ',
  42. ' Published ' tinyint (1) not NULL DEFAULT ' 0 ',
  43. ' module ' varchar DEFAULT NULL,
  44. ' Numnews ' int (one) not NULL DEFAULT ' 0 ',
  45. ' Access ' tinyint (3) unsigned not NULL DEFAULT ' 0 ',
  46. ' Showtitle ' tinyint (3) unsigned not NULL DEFAULT ' 1 ',
  47. ' Params ' text is not NULL,
  48. ' Iscore ' tinyint (4) not NULL DEFAULT ' 0 ',
  49. ' client_id ' tinyint (4) not NULL DEFAULT ' 0 ',
  50. ' Control ' text is not NULL,
  51. PRIMARY KEY (' id '),
  52. KEY ' published ' (' published ', ' Access '),
  53. KEY ' newsfeeds ' (' Module ', ' published ')
  54. ) Engine=myisam auto_increment=145 DEFAULT Charset=utf8
  55. 3, use INFORMATION_SCHEMA; SELECT * from columns where table_name=' tablename '
  56. For example:
  57. To view the Jos_modules table Structure command:
  58. Use INFORMATION_SCHEMA;
  59. SELECT * from columns where table_name=' jos_modules ';

Ways to view MySQL table structure and table creation statements

Related Article

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.