Əsas səhifə
> My Stored Routines > Alter Table Charset and Collation
Alter Table Charset and Collation
DELIMITER $$ CREATE DEFINER=`root`@`127.0.0.1` PROCEDURE `multiple_alter_table_charset`() BEGIN declare v_table_name varchar(30); declare v_last_row_fetched int default 0; declare v_table_schema varchar(30); declare cursor1 cursor for select table_schema,table_name from information_schema.tables where table_schema not in ('mysql' , 'performance_schema', 'information_schema') and table_type = 'base table' and table_collation = 'latin1_swedish_ci'; declare continue handler for not found set v_last_row_fetched=1; set v_last_row_fetched=0; open cursor1; cursor_loop: loop fetch cursor1 into v_table_schema,v_table_name; if v_last_row_fetched=1 then leave cursor_loop; end if; set @sql_v=concat('alter table ',v_table_schema,'.',v_table_name,' CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci'); prepare stmt from @sql_v; EXECUTE stmt; deallocate prepare stmt; end loop cursor_loop; close cursor1; set v_last_row_fetched=0; END$$
Procedure bütün latin1-ləri tapır və hamısını UTF8-ə çevirir
*Diqqət!!! Production-da istifadə etməzdən əvvəl hər hansı bir ERROR əleyhinə test-də sınamaq məsləhətdir.*
Kateqoriyalar: My Stored Routines
Şərhlər (0)
Trackbacks (0)
Bir şərh yazın
Geri İzləmə