Statements used to obtain MySQL table information

Source: Internet
Author: User
Tags mysql update mysql index

The SQL statements described below can obtain important information such as MySQL table information and foreign key relationships, which is of great value. If you have encountered similar problems in MySQL table information, take a look.

 
 
  1. /* Obtain table information */
  2. Select table_Comment as Script, table_Name as TableName, 0 as id, Create_Time as createDate,
  3. CASE table_Type WHEN 'base table' then' U 'when' VIEW 'then' V 'else table_Type END as tableType,
  4. 0 as Category from tables;
  5.  
  6. /* Obtain the foreign key relationship */
  7. SELECT CONSTRAINT_Name as Script, CONSTRAINT_Name as TableName, 0 as id,
  8. CURRENT_TIMESTAMP as createDate,
  9. CASE CONSTRAINT_TYPE
  10. WHEN 'forn n key' THEN 'F'
  11. WHEN 'Primary key'then 'K'
  12. ELSE CONSTRAINT_TYPE
  13. End as tableType, 0 as Category From TABLE_CONSTRAINTS;
  14.  
  15. SELECT Table_Name, Column_Name, Column_Type, Column_Key, Column_Comment From Columns;
  16.  
  17. /* Obtain column information */
  18. Select table_name as tablename, column_Name as columnName, column_type as columnType,
  19. 0 as columntypeindex, CHARACTER_OCTET_LENGTH as length, Numeric_Precision as decimaldigits,
  20. Column_comment as Script, column_default as defaultvalue, is_nullable as isnullable,
  21. Case extra when 'Auto _ secret' then 1 else 0 end as IsMarking,
  22. 0 as colid, 'U' as ObjectType, data_type from columns;

The preceding statement is used to obtain MySQL table information.

MySQL statements commonly used in PHP

How to find slow SQL statements in mysql

How to use mysql UPDATE statements

General INSERT usage in MySQL

MySQL index type

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.