MySQL - 以不同语言或特殊符号存储字符

时间:2010-03-25 19:17:17

标签: mysql

我需要在MySQL中创建一个表,它存储世界上不同国家的不同货币符号。这些符号使用不同的语言,并没有插入到数据库中,并且会引发错误,如

incorrect string value xd8\x8b

示例数据是:

insert into country ( country_name, currency_name, currency_code, currency_symbol) values 
('Afghanistan','Afghanis','AFN',' ؋'),
('Aruba','Guilders','AWG',' ƒ'),
('Azerbaijan','New Manats','AZN',' ман'),
('Bulgaria','Leva','BGN',' лв'),
('Costa Rica','Colón','CRC',' ₡'),
('Cuba','Pesos','CUP',' ₱'),
('Cyprus','Euro','EUR',' €'),
('Czech Republic','Koruny','CZK',' Kč'),
('Ghana','Cedis','GHC',' ¢'),
('Iran','Rials','IRR',' ﷼'),
('Israel','New Shekels','ILS',' ₪'),
('Japan','Yen','JPY',' ¥'),
('Kazakhstan','Tenge','KZT',' лв'),
('Korea','Won','KPW',' ₩'),
('Laos','Kips','LAK',' ₭'),
('Macedonia','Denars','MKD',' ден'),
('Mongolia','Tugriks','MNT',' ₮'),
('Nigeria','Nairas','NGN',' ₦'),
('Pakistan','Rupees','PKR',' ₨'),
('Russia','Rubles','RUB',' руб'),
('Vietnam','Dong','VND',' ₫'),
('Yemen','Rials','YER',' ﷼');

我正在使用MySQL 5.1.22,这是当前的表结构:

CREATE TABLE `country` (
  `country_id` int(11) NOT NULL AUTO_INCREMENT,
  `country_name` varchar(100) DEFAULT NULL,
  `currency_name` varchar(100) DEFAULT NULL,
  `currency_code` varchar(20) DEFAULT NULL,
  `currency_symbol` varchar(20) DEFAULT NULL,
  `date_created` datetime DEFAULT NULL,
  `last_modified` datetime DEFAULT NULL,
  PRIMARY KEY (`country_id`)
) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=latin1;

只是将CHARSET更改为其他内容吗?

1 个答案:

答案 0 :(得分:3)

是。将字符集更改为UTF8。