MySQL learning footprint record 01-SOURCE, SHOW

Source: Internet
Author: User

MySQL learning footprint record 01-SOURCE, SHOW 1. Import Data

  command:   SOURCE <PATH> <data.sql>; eg:   mysql> source ~/MyDoc/create.sql;

 

2. the shortcut for show columns from <table_name> is DESCRIBE <table_name>
  eg:    mysql> SHOW COLUMNS FROM orders;+------------+----------+------+-----+---------+----------------+| Field      | Type     | Null | Key | Default | Extra          |+------------+----------+------+-----+---------+----------------+| order_num  | int(11)  | NO   | PRI | NULL    | auto_increment || order_date | datetime | NO   |     | NULL    |                || cust_id    | int(11)  | NO   | MUL | NULL    |                |+------------+----------+------+-----+---------+----------------+mysql> DESCRIBE orders;+------------+----------+------+-----+---------+----------------+| Field      | Type     | Null | Key | Default | Extra          |+------------+----------+------+-----+---------+----------------+| order_num  | int(11)  | NO   | PRI | NULL    | auto_increment || order_date | datetime | NO   |     | NULL    |                || cust_id    | int(11)  | NO   | MUL | NULL    |                |+------------+----------+------+-----+---------+----------------+

 

3. Display Server Status Information
  command:      SHOW STATUS;   eg:     mysql> SHOW STATUS;+------------------------------------------+-------------+| Variable_name                            | Value       |+------------------------------------------+-------------+| Aborted_clients                          | 0           || Aborted_connects                         | 0           | ......... .........

 

4. Show the authorized users
  command:     SHOW GRANTS; eg:   mysql> SHOW GRANTS;+----------------------------------------------------------------------------------------------------------------------------------------+| Grants for root@localhost     ....... .......

 

5. Display Error Information
  command:     SHOW ERRORS; eg:   mysql> SHOW ERRORS;+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------+| Level | Code | Message     ....... .......

 

6. display warning information
  command:     SHOW WARMMINGS; eg:   mysql> SHOW WARMMINGS;ERROR 1064 (42000): You have an error in your SQL syntax;  ....... .......

 

7. Display statements for creating a specific database
  command:        SHOW CREATE DATABASE <database_name>;   eg:     mysql> SHOW CREATE DATABASE MySQL_ex;+----------+---------------------------------------------------------------------+| Database | Create Database                                                     |+----------+---------------------------------------------------------------------+| MySQL_ex | CREATE DATABASE `MySQL_ex` /*!40100 DEFAULT CHARACTER SET latin1 */ |+----------+---------------------------------------------------------------------+1 row in set (0.00 sec)

 

8. display the statement for creating a specific table
  command:        SHOW CREATE TABLE <database_name>;   eg:     mysql> SHOW CREATE TABLE orders;+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| Table  | Create Table                                                                                                                                                                                                                                                                                                                                                           |+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| orders | CREATE TABLE `orders` (  `order_num` int(11) NOT NULL AUTO_INCREMENT,  `order_date` datetime NOT NULL,  `cust_id` int(11) NOT NULL,  PRIMARY KEY (`order_num`),  KEY `fk_orders_customers` (`cust_id`),  CONSTRAINT `fk_orders_customers` FOREIGN KEY (`cust_id`) REFERENCES `customers` (`cust_id`)) ENGINE=InnoDB AUTO_INCREMENT=20010 DEFAULT CHARSET=latin1 | ....

 

9. Other SHOW commands help show;

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.