1 将查询数据导出

select * from person where id<500 into outfile 'D:\\person_data.txt'

语法: sql 查询 into outfile ‘目标路径’

注意:需要mysql目录下的my.ini文件中的 secure_file_priv=null 改为 secure_file_priv=

 

2 将数据导入指定表

load data infile 'C:\\Users\\admin\\Desktop\\person_data.txt' into table person1(id,name,age);

语法:load data infile '文件路径' into table 表名(指定字段1,指定字段2,指定字段3)