Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this questionI am documenting a database, and it would be great to have the functionality to update the tables automatically based on the current state of the database.
I know phpmyadmin doe开发者_开发问答s this, but it is a buggy gui that doesn't provide many options- so I end up having to write a script with sed to find and replace things that I don't want and add things that I do.
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.
精彩评论