码迷,mamicode.com
首页 > 数据库 > 详细

批量修改mysql 备注

时间:2018-10-17 15:45:35      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:name   orm   select   tab   schema   alter   where   批量修改   not   

SELECT
concat(
"ALTER TABLE ",
TABLE_SCHEMA,
".",
TABLE_NAME,
" CHANGE ",
COLUMN_NAME,
" ",
COLUMN_NAME,
" ",
COLUMN_TYPE,

IF (
    COLUMN_DEFAULT IS NULL,
    " ",
    concat(
        " DEFAULT ",

    IF (
        COLUMN_DEFAULT = ‘‘,
        "‘‘",
        COLUMN_DEFAULT
    )
    )
),

IF (
IS_NULLABLE = ‘NO‘,
" NOT NULL ",
‘‘
),
" COMMENT ",
" ",
"‘",
LEFT (
COLUMNS .COLUMN_NAME,
instr(COLUMNS .COLUMN_NAME, ‘F‘) - 1
),
"‘;"
)
FROM
information_schema. COLUMNS
WHERE
TABLE_NAME = ‘j_data_wa_grgz‘
AND COLUMNS .COLUMNNAME LIKE ‘%F%‘

批量修改mysql 备注

标签:name   orm   select   tab   schema   alter   where   批量修改   not   

原文地址:http://blog.51cto.com/changmen/2301147

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!