程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> MySQL學習足跡記錄01--SOURCE,SHOW

MySQL學習足跡記錄01--SOURCE,SHOW

編輯:MySQL綜合教程

MySQL學習足跡記錄01--SOURCE,SHOW   1.導入數據

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

 

  2.SHOW COLUMNS FROM <table_name>的快捷方式為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.顯示服務器狀態信息
  command:
      SHOW STATUS;
   eg:
     mysql> SHOW STATUS;
+------------------------------------------+-------------+
| Variable_name                            | Value       |
+------------------------------------------+-------------+
| Aborted_clients                          | 0           |
| Aborted_connects                         | 0           |

 .........
 .........

 

  4.顯示授予用戶
  command:
     SHOW GRANTS;
 eg:
   mysql> SHOW GRANTS;
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost  
  
 .......
 .......

 

  5.顯示錯誤信息
  command:
     SHOW ERRORS;
 eg:
   mysql> SHOW ERRORS;
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message  
  
 .......
 .......

 

  6.顯示警告信息
  command:
     SHOW WARMMINGS;
 eg:
   mysql> SHOW WARMMINGS;
ERROR 1064 (42000): You have an error in your SQL syntax; 
 .......
 .......

 

  7.顯示創建特定數據庫的語句
  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.顯示創建特定表格的語句
  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.其他SHOW命令    HELP SHOW;      

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved