mysql清除注释,需要分两步骤!
- 通过SQL语句得到数据库中所有的注销信息,拼接为执行SQL语句 ;
- 执行对应得到是SQL语句 ;
获取去除表注释SQL
SELECT
concat(
'alter table ',
table_schema,
'.',
table_name,
' comment ''',
''';'
) table_ant
FROM
information_schema. COLUMNS
WHERE
table_schema = '数据库名称'
GROUP BY
TABLE_NAME;
将查询得到SQL语句进行复制,执行即可去除表对应的注释信息。
获取去除表对应字段注释SQL
SELECT
concat(
'alter table ',
table_schema,
'.',
table_name,
' modify column `',
column_name,
'` ',
column_type,
IF (
is_nullable = 'YES',
IF (
data_type IN ('timestamp'),
' null ',
' '
),
' not null '
),
IF (
column_default IS NULL,
'',
IF (
data_type IN ('char', 'varchar')
OR data_type IN ('date', 'datetime')
AND column_default != 'CURRENT_TIMESTAMP',
concat(
' default ''',
column_default,
''''
),
concat(
' default ',
IF (
column_default = '',
'''''',
column_default
)
)
)
),
IF (
extra IS NULL
OR extra = '',
'',
concat(' ', extra)
),
' comment ''',
''';'
) s
FROM
information_schema. COLUMNS
WHERE
table_schema = '数据库名称';
将查询得到SQL语句进行复制,执行即可去除表字段对应的注释信息。