- 論壇徽章:
- 0
|
環(huán)境:MySQL 5.1.50-community,Windows XP
目的:從文本文件test.txt中導(dǎo)入數(shù)據(jù)到MySQL中
test.txt中內(nèi)容如下:
045001, 武曉霞, 0, 1981.07.16, 漢族, 中共黨員, 物理電子學(xué), 林金桐, 吉林大學(xué), 推薦免試, 非定向, , 電信工程學(xué)院
045002, 薛偉琦, 1, 1978.09.12, 漢族, 其他, 物理電子學(xué), 林金桐, 上海光學(xué)精密機械研究所, 全國統(tǒng)考, 非定向, , 電信工程學(xué)院
045003, 鄒璟宜, 0, 1982.02.08, 漢族, 共青團員, 物理電子學(xué), 林金桐, 浙江大學(xué)信息學(xué)院光電系, 全國統(tǒng)考, 自籌, , 電信工程學(xué)院
為此,在MySQL中創(chuàng)建數(shù)據(jù)庫及表結(jié)構(gòu)如下:
create database `enroll`;
use enroll;
create table `postgraduate`(
id mediumint(8 ) unsigned not null,
name char(15) not null default '',
gender tinyint(1) not null default '0',
birthdate date not null default '0000-00-00',
nation char(10) not null default '',
party char(10) not null default '',
major char(22) not null default '',
tutor char(15) not null default '',
source_from varchar(50) not null default '',
method char(12) not null default '',
class char(6) not null default '',
to_train varchar(30),
colleage char(22) not null default '',
primary key (`id`)
)default charset=gbk;
然后,利用Load data…infile語句導(dǎo)入(我的測試文件test.txt就放在D盤根目錄下面):
load data infile 'd:/test.txt' into table postgraduate fields terminated by ',';
出錯信息:ERROR 1366 (HY000): Incorrect string value: '\xADZ\xD2\xCB' for column 'name' at row 3
開始一直不知道怎么回事,后來將上面的數(shù)據(jù)表的存儲引擎改為engine=myisam后(其余操作不變),就能正確導(dǎo)入了。
請問存儲引擎對這個還有影響么?(開始WINDOWS平臺下默認的存儲引擎為InnoDB。)
請幫我測試一下,花不了您多長時間,謝謝! |
|