make mysqldump to sort columns alphabetically
2 answers - 399 bytes -

Hi,
I'm diffing two versions of a schema produced using mysqldump and would
like to know if there's a way to make mysqldump sort entries inside
CREATE statements (say alphabetically or in some other way)? Currently
some of the column declarations are juxtaposed between the versions and
thus produce "false" diffs.
Mysql 5.0, InnoDB
thanks a lot
-nikita
No.1 | | 1531 bytes |
| 
way you could solve this is to conform the column orders between
the two versions.
For example, if one table, t6, has columns id, name, and address and
the same table in the second database is id, address, name, you could
just ALTER the second database t6 table to be id, name, address:
mysqldescribe t6;
| Field | Type | Null | Key | Default | Extra |
| id | int(9) | N | PRI | 0 | |
| address | varchar(32) | YES | | | |
| name | varchar(32) | YES | MUL | | |
3 rows in set (0.00 sec)
mysqlalter table t6 change column address address varchar(32) after
name;
Query K, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysqldescribe t6;
| Field | Type | Null | Key | Default | Extra |
| id | int(9) | N | PRI | 0 | |
| name | varchar(32) | YES | MUL | | |
| address | varchar(32) | YES | | | |
3 rows in set (0.00 sec)
Here is the mysql documentation on ALTER TABLE: http://dev.mysql.com/
Douglas Sims
Doug (AT) Apley (DOT) com
Sep 8, 2006, at 12:27 PM, Nikita Tovstoles wrote:
Hi,
I'm diffing two versions of a schema produced using mysqldump and
would like to know if there's a way to make mysqldump sort entries
inside CREATE statements (say alphabetically or in some other way)?
Currently some of the column declarations are juxtaposed between
the versions and thus produce "false" diffs.
Mysql 5.0, InnoDB
thanks a lot
-nikita
--
No.2 | | 2394 bytes |
| 
Thanks, Douglas!
That seems K, but I'd prefer to avoid altering the schemas in any way.
In particular altering order of constraints seems error-prone, given
that one is essentially re-defining these, not simply rearranging the
order. Am I asking for impossible? ;-
-nikita
Douglas Sims wrote:
way you could solve this is to conform the column orders between
the two versions.
For example, if one table, t6, has columns id, name, and address and
the same table in the second database is id, address, name, you could
just ALTER the second database t6 table to be id, name, address:
mysqldescribe t6;
| Field | Type | Null | Key | Default | Extra |
| id | int(9) | N | PRI | 0 | |
| address | varchar(32) | YES | | | |
| name | varchar(32) | YES | MUL | | |
3 rows in set (0.00 sec)
mysqlalter table t6 change column address address varchar(32) after
name;
Query K, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysqldescribe t6;
| Field | Type | Null | Key | Default | Extra |
| id | int(9) | N | PRI | 0 | |
| name | varchar(32) | YES | MUL | | |
| address | varchar(32) | YES | | | |
3 rows in set (0.00 sec)
Here is the mysql documentation on ALTER TABLE:
>
>
>
Douglas Sims
Doug (AT) Apley (DOT) com
>
>
>
Sep 8, 2006, at 12:27 PM, Nikita Tovstoles wrote:
>
>Hi,
>>
>I'm diffing two versions of a schema produced using mysqldump and
>would like to know if there's a way to make mysqldump sort entries
>inside CREATE statements (say alphabetically or in some other way)?
>Currently some of the column declarations are juxtaposed between the
>versions and thus produce "false" diffs.
>>
>Mysql 5.0, InnoDB
>>
>thanks a lot
>-nikita
>>
>>
>General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe: @apley.com
>
>
General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
@doppelganger.com