1. 程式人生 > >mysql批量修改列型別-生成語句

mysql批量修改列型別-生成語句

SELECT 
  CONCAT(
    'alter table ',
    table_name,
    ' MODIFY COLUMN ',
    column_name,
    ' float  DEFAULT NULL;'
  ) AS col,
  TABLE_NAME,
  COLUMN_NAME,
  DATA_TYPE 
FROM
  INFORMATION_SCHEMA.columns a 
WHERE TABLE_SCHEMA = 'prod_db' -- 代表所在的資料庫
  AND data_type IN ('double') -- 批量修改的型別