August 11th, 2009

MySQL Change Character Set

I needed to change the character set for a MySQL database with which I'm working. It was created with latin1 and I needed it to be in utf-8. Here are some relevant links.

My need was pretty simple, convert the database without to much concern for the data itself. So my main challenge was how to loop over the tables in my database and alter the tables. I decided to use the mysql command line. Here is what I came up with...

USE databasename;

DELIMITER //

DROP PROCEDURE IF EXISTS test//

CREATE PROCEDURE test()

    BEGIN

      DECLARE done INT DEFAULT 0;
      DECLARE a CHAR(64);
      DECLARE cur1 CURSOR FOR SHOW TABLES;
      DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

      OPEN cur1;

      LOOP

        FETCH cur1 INTO a;

        IF NOT done THEN

          SET @s = CONCAT('ALTER TABLE ',a,' CONVERT TO CHARACTER SET utf8');

          PREPARE stmt FROM @s;

          EXECUTE stmt;

          DEALLOCATE PREPARE stmt;

        END IF;

      END LOOP;

      CLOSE cur1;

    END//

DELIMITER ;

Comments (0)       
Tags: change, character, latin1, mysql, set, utf-8

Ксения Симонова - Реквием из песка

This is some truly stunning art!

Comments (0)       

Nagoya Robot Ramen

I found this somewhat fascinating and then a little disturbing when the robots started to entertain with a spinning plate and knife play.

Comments (0)       
Tags: food, japan, ramen, robot, technology

Own A Real Star Trek Phaser

Nice. Here is a model kit based on the Type 1 Phaser of Star Trek TOS.

There's no shortage of Star Trek paraphernalia, but this Star Trek Hero Type-I Phaser Kit gives you exactly the same prop that was used on the original Star Trek series. You can be sure this replica will have the same look and feel of the original, because it was "molded off an original prop for perfect accuracy."

star trek tos type 1 phaser model kit

Comments (0)       
Tags: kit, model, phaser, sci-fi, star trek, tos, type 1, via dvice

<  August 2009  >
SunMonTueWedThuFriSat
      1
2345678
9101112131415
16171819202122
23242526272829
3031