It may not be an easy task to reconcile what has and has not changed. But, the basic approach here is to get a list of the tables in a database, and then run the SHOW CREATE TABLE table_name command for a full spec on the schema. Also, you could use the EXPLAIN command; however, though it's similar, it also contains higher-level information. I'd argue that SHOW CREATE is best since that's all you need to see to replicate the schema.
If I had more specifics about how you wanted to use this information, I'd ammend this with more information. Especially what programming language you're using to connect to mysql. You can actually even use the command line to get this info, but you'll want some intelligent processing in order to do a reconciliation against existing fields in your replicated data containers.
发布评论
评论(1)
您可以通过 SHOW TABLES 和 显示创建表命令。
协调已经发生的变化和未发生的变化可能不是一件容易的事。但是,这里的基本方法是获取数据库中的表列表,然后运行 SHOW CREATE TABLE table_name 命令以获得架构的完整规范。另外,您可以使用 EXPLAIN 命令;然而,尽管它很相似,但它还包含更高级别的信息。我认为 SHOW CREATE 是最好的,因为这就是复制模式所需的全部内容。
如果我有更多关于您想如何使用此信息的具体信息,我会用更多信息对此进行修改。特别是你使用什么编程语言来连接 mysql。实际上,您甚至可以使用命令行来获取此信息,但您需要进行一些智能处理,以便对复制数据容器中的现有字段进行协调。
You can accomplish this via SHOW TABLES and SHOW CREATE TABLE command.
It may not be an easy task to reconcile what has and has not changed. But, the basic approach here is to get a list of the tables in a database, and then run the
SHOW CREATE TABLE table_name
command for a full spec on the schema. Also, you could use the EXPLAIN command; however, though it's similar, it also contains higher-level information. I'd argue that SHOW CREATE is best since that's all you need to see to replicate the schema.If I had more specifics about how you wanted to use this information, I'd ammend this with more information. Especially what programming language you're using to connect to mysql. You can actually even use the command line to get this info, but you'll want some intelligent processing in order to do a reconciliation against existing fields in your replicated data containers.