I’ve built a tool that compares the tables and the table structure between two databases. I have managed to get the tool to the point where it will detect the differences of one table against another and now I’m trying to put the icing on the cake by making the tool also generate the SQL code to correct the difference. The two kinds of differences I’m having trouble with is the adding of a missing column and the altering of an existing one. I’ve googled for a while now and I’m confused as to what exactly I need to do as every example I’ve found has different syntaxes to add/alter columns. So what I would like to know is in which order do I put the following column attributes.
Field, Type, Null, Key, Default, Extra
I know the syntax is something like “alter table table_name add column Field, Not Null, Key, Default =, extra stuff here etc” but for the life of me I can’t seem to figure it out. If you wouldn’t mind throwing me a bone here I’d really appreciate it.
I should also add, my tool is reporting that a column with the name trans_id is differing because it’s key is set to “MUL”. I don’t quite understand what this means or how to set it. I normally use PHPMYADMIN to adjust things like this and I can’t find any documentation on how to set a key to MUL or remove MUL from a key. Oddly enough both columns appear to function completely fine.