Nikita,

Try somehting like this:

mysql -hHOST -uUSER -pPASS -s -e'show tables' DATABASE | \
tail +1 | \
while read TABLE
do
        echo == $TABLE ==
        mysql -s -pwmihp -e"describe $TABLE" articles | sort
Done

I used the "tail +1" to trim out the header row -- tho I think there is
an option to make output less verbose.


 

> -----Original Message-----
> From: Nikita Tovstoles [mailto:[EMAIL PROTECTED] 
> Sent: Friday, September 08, 2006 2:00 PM
> To: mysql@lists.mysql.com
> Subject: Re: make mysqldump to sort columns alphabetically
> 
> Thanks, Douglas!
> 
> That seems OK, 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:
> > One 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:
> >
> > mysql> describe t6;
> > +---------+-------------+------+-----+---------+-------+
> > | Field   | Type        | Null | Key | Default | Extra |
> > +---------+-------------+------+-----+---------+-------+
> > | id      | int(9)      | NO   | PRI | 0       |       |
> > | address | varchar(32) | YES  |     |         |       |
> > | name    | varchar(32) | YES  | MUL |         |       |
> > +---------+-------------+------+-----+---------+-------+
> > 3 rows in set (0.00 sec)
> >
> > mysql> alter table t6 change column address address 
> varchar(32) after
> > name;
> > Query OK, 0 rows affected (0.02 sec)
> > Records: 0  Duplicates: 0  Warnings: 0
> >
> > mysql> describe t6;
> > +---------+-------------+------+-----+---------+-------+
> > | Field   | Type        | Null | Key | Default | Extra |
> > +---------+-------------+------+-----+---------+-------+
> > | id      | int(9)      | NO   | 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/doc/refman/5.0/en/alter-table.html
> >
> >
> >
> > Douglas Sims
> > [EMAIL PROTECTED]
> >
> >
> >
> > On 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
> >>
> >>
> >> --MySQL General Mailing List
> >> For list archives: http://lists.mysql.com/mysql
> >> To unsubscribe:    
> http://lists.mysql.com/[EMAIL PROTECTED]
> >
> >
> > --MySQL General Mailing List
> > For list archives: http://lists.mysql.com/mysql
> > To unsubscribe:    
> > http://lists.mysql.com/[EMAIL PROTECTED]
> >
> 
> 
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    
> http://lists.mysql.com/[EMAIL PROTECTED]
> 
> 

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to