Home > Database > Mysql Tutorial > body text

Introduction to mysql structure comparison (code example)

不言
Release: 2019-02-21 11:48:56
forward
1928 people have browsed it

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

The reason for the gadget

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", &#39;0&#39;, "0");

//开发环境的数据库
$newConfig = mysqldiff\db\MysqlConfig::make("0", "0", &#39;0&#39;, "0");


$model = new \mysqldiff\Run($config, $newConfig);
$model->exec();
Copy after login

Execution results

#########新增表############

#########修改表############

#########索引变化############
表--
删除索引
ALTER TABLE `--` DROP INDEX `INDEX_TITLE`
添加索引
ALTER TABLE `--` ADD UNIQUE KEY `update_time`(`update_time`)
Copy after login

Built-in database, information_schema introduction

1 Record all database information (related recommendations: MySQL tutorial)

  1. SCHEMATA: Provides information about all databases in the current mysql instance, including character encoding

  2. TABLES: Records that the database contains all tables Information

  3. COLUMNS: Information about each column in the table

  4. STATISTICS table: Provides information about table indexes. The result of show index from schemaname.tablename is taken from this table

  5. 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!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!