標籤:辛星 mysql 中繼資料 show 資料庫
首先解釋一下什麼是中繼資料,所謂中繼資料,就是表示資料的資料,這些資料五花八門,總之,只要不是我們儲存到資料庫裡的資料,大多都可以理解為中繼資料。那麼我們如何來擷取這些中繼資料呢?
總的來說,有三種思路,第一種,各種show,第二種,各種select,第三種,是mysql的命令列下的命令,不是sql語句。
我們首先看第一種,這裡我列舉一下大家比較熟悉的show語句的用法,其實咱們經常用show來查看資訊,比如:
show databases;show tales;show create table 表名;show index from 表名;....等等
第二種就是通過select來從mysql資料庫或者information_schema資料庫中提取相關資訊,比如可以從tables這個表裡面的free_data欄位來查看資料片段的相關資訊,這裡我上一篇博文已經介紹過了,這裡就不廢話了。
第三種就是通過mysql內建的一些命令來查看,這個需要咱們的使用者名稱和密碼的,下面是我查看相應中繼資料的代碼,希望能幫到您:
Microsoft Windows [版本 6.1.7601]著作權 (c) 2009 Microsoft Corporation。著作權所有,並保留一切權利。C:\Users\Administrator>mysqlshow -u root -prootmysqlshow: [Warning] Using a password on the command line interface can be insecure.+--------------------+| Databases |+--------------------+| information_schema || mysql || performance_schema || test || xinxing |+--------------------+C:\Users\Administrator>mysqlshow -u root -proot xinxingmysqlshow: [Warning] Using a password on the command line interface can be insecure.Database: xinxing+--------+| Tables |+--------+| xin |+--------+C:\Users\Administrator>mysqlshow -u root -proot --status xinxingmysqlshow: [Warning] Using a password on the command line interface can be insecure.Database: xinxing+------+--------+---------+------------+------+----------------+-------------+-------------------+--------------+-----------+----------------+---------------------+---------------------+---------------------+-----------------+----------+----------------+---------+| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |+------+--------+---------+------------+------+----------------+-------------+-------------------+--------------+-----------+----------------+---------------------+---------------------+---------------------+-----------------+----------+----------------+---------+| xin | MyISAM | 10 | Fixed | 3 | 121 | 363 | 34058472181989375 | 1024 | 0 | | 2014-08-25 13:19:02 | 2014-08-25 13:41:25 | 2014-08-25 13:41:25 | utf8_general_ci | | | |+------+--------+---------+------------+------+----------------+-------------+-------------------+--------------+-----------+----------------+---------------------+---------------------+---------------------+-----------------+----------+----------------+---------+C:\Users\Administrator>
下面是我用mysqldump來查看錶結構的一些操作,希望對您有用:
C:\Users\Administrator>mysqldump -u root -proot --no-data xinxing xinmysqldump: [Warning] Using a password on the command line interface can be insecure.-- MySQL dump 10.13 Distrib 5.7.3-m13, for Win64 (x86_64)---- Host: localhost Database: xinxing-- -------------------------------------------------------- Server version 5.7.3-m13/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;/*!40101 SET @[email protected]@COLLATION_CONNECTION */;/*!40101 SET NAMES utf8 */;/*!40103 SET @[email protected]@TIME_ZONE */;/*!40103 SET TIME_ZONE='+00:00' */;/*!40014 SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;/*!40014 SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;/*!40101 SET @[email protected]@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;/*!40111 SET @[email protected]@SQL_NOTES, SQL_NOTES=0 */;---- Table structure for table `xin`--DROP TABLE IF EXISTS `xin`;/*!40101 SET @saved_cs_client = @@character_set_client */;/*!40101 SET character_set_client = utf8 */;CREATE TABLE `xin` ( `c` char(40) DEFAULT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8;/*!40101 SET character_set_client = @saved_cs_client */;/*!40103 SET [email protected]_TIME_ZONE */;/*!40101 SET [email protected]_SQL_MODE */;/*!40014 SET [email protected]_FOREIGN_KEY_CHECKS */;/*!40014 SET [email protected]_UNIQUE_CHECKS */;/*!40101 SET [email protected]_CHARACTER_SET_CLIENT */;/*!40101 SET [email protected]_CHARACTER_SET_RESULTS */;/*!40101 SET [email protected]_COLLATION_CONNECTION */;/*!40111 SET [email protected]_SQL_NOTES */;-- Dump completed on 2014-08-25 20:49:08
辛星,期待您的關注。。
辛星淺談mysql中的中繼資料