mysql清除注釋,分兩步
邏輯:通過sql語句能查詢數(shù)據(jù)庫中的全部備注信息,然后將備注信息拼接成一個(gè)修改sql。
1.清除字段注解
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 = '數(shù)據(jù)庫名稱';
2.清除表注解
SELECT concat( 'alter table ', table_schema, '.', table_name, ' comment ''', ''';' ) s FROM information_schema.COLUMNS WHERE table_schema = '數(shù)據(jù)庫名稱' GROUP BY TABLE_NAME;
以上查詢出來的語句,放到mysql執(zhí)行就大功告成啦!

浙公網(wǎng)安備 33010602011771號