Home >Database >Mysql Tutorial >Introduction to mysql structure comparison (code example)
This article brings you an introduction to mysql structure comparison (code examples). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Gadget addressClick, just for verification
Daily development often encounters database structure changes, but they cannot be recorded in real time , after going online, it will cause inconsistency between the test and the online database structure;
This small tool mainly solves this problem; it mainly verifies whether the updated data structure is consistent
How to use
<?php include_once __DIR__ . "/../vendor/autoload.php"; //目前线上的数据库 $config = mysqldiff\db\MysqlConfig::make("0", "0", '0', "0"); //开发环境的数据库 $newConfig = mysqldiff\db\MysqlConfig::make("0", "0", '0', "0"); $model = new \mysqldiff\Run($config, $newConfig); $model->exec();
#########新增表############ #########修改表############ #########索引变化############ 表-- 删除索引 ALTER TABLE `--` DROP INDEX `INDEX_TITLE` 添加索引 ALTER TABLE `--` ADD UNIQUE KEY `update_time`(`update_time`)
1 Record all database information (related recommendations: MySQL tutorial)
SCHEMATA: Provides information about all databases in the current mysql instance, including character encoding
TABLES: Records that the database contains all tables Information
COLUMNS: Information about each column in the table
STATISTICS table: Provides information about table indexes. The result of show index from schemaname.tablename is taken from this table
USER_PRIVILEGES (user permissions) table: gives information about full permissions. This information is derived from the mysql.user authorization table. Yes and non-standard table
The above is the detailed content of Introduction to mysql structure comparison (code example). For more information, please follow other related articles on the PHP Chinese website!