Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I posted this question on stack overflow, but his might be a better place for it. Reference: http://stackoverflow.com/questions/23498901/mysql-update-default-value-of-column-in-multiple-tables-from-an-inner-select-sta

I need to update the default value of all Synced fields in a database tables.

I've looked at several other posts and put together the following, which I'm missing something, any ideas?

ALTER TABLE (
  SELECT 
    DISTINCT
      TABLE_NAME
  FROM
    INFORMATION_SCHEMA.COLUMNS
  WHERE 
    TABLE_SCHEMA != 'mysql'
    AND TABLE_SCHEMA != 'information_schema'
    AND COLUMN_NAME = 'Synced'
  ORDER BY 
    TABLE_NAME ASC)
CHANGE `Synced` `Synced` TINYINT DEFAULT 0;

I've referenced the following to put it together:

Any help is appreciated.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.