Menu

#839 Export structure as alter table

Needs_decision
fixed
nobody
Normal
2015-06-21
2005-12-05
No

Hi,

Would it be possible to add an option to export table
structures as single alter table statements?
That's quite handy if you want to update a table
structure to the 'next version'.

Discussion

  • Michal Čihař

    Michal Čihař - 2005-12-05

    Logged In: YES
    user_id=192186

    You mean diff of two tables?

     
  • Michal Čihař

    Michal Čihař - 2005-12-05

    Logged In: YES
    user_id=192186

    See RFE#631976 for that. I don't see other way to find out
    which fields to alter or add.

     
  • Olaf van der Spek

    Logged In: YES
    user_id=30264

    No, I don't.
    I'm not sure if alter table allows you to say alter column
    if exists, add otherwise, but if it does, that'd be the
    best way. Just generate one alter table statement per
    column.
    If it doesn't, you could simply first generate add column
    and then alter column and ignore the failure of the add.

     
  • Michal Čihař

    Michal Čihař - 2005-12-05

    Logged In: YES
    user_id=192186

    You can not say add if not exists. There is also no generic
    way to ignore errors in SQL, so this won't work. I still
    don't see other usable solution than diff.

     
  • Olaf van der Spek

    Logged In: YES
    user_id=30264

    A diff requires both versions of the table structure to be
    available and I don't think that's always the case.

    A dump of alter statements is still handy if
    you're 'manually' updating a table structure.
    And I think the mysql 'console' client will simply give an
    error but you can still paste all statements at once.

     
  • Michal Čihař

    Michal Čihař - 2005-12-06

    Logged In: YES
    user_id=192186

    So you want ALTER TABLE blah CHANGE or ALTER TABLE blah ADD?

     
  • Olaf van der Spek

    Logged In: YES
    user_id=30264

    Either give the choice between those to the user or simply
    include both in the output (first add, then change).

     
  • Marc Delisle

    Marc Delisle - 2015-06-21

    I believe that this has been covered in the Tracking mechanism.

     
  • Marc Delisle

    Marc Delisle - 2015-06-21
    • status: open --> fixed
    • Group: --> Needs_decision