您的位置:首页 > 博客中心 > 数据库 >

mysql的导入

时间:2022-03-13 22:53

方法1

load data [local] infile ‘filename‘ into table tablename[option]

ields terminated by ‘string‘(字段分隔符,默认为字表符‘\t‘);

fields [optionally] enclosed by ‘char‘(字段引用符,如果加optionally选项择只能用在char,varchar,text等字符型字段上,默认不使用引用符)

fields escaped by ‘char‘ (转义字符,默认为‘\‘)
lines staring by ‘string‘ 每行前都加此字符串,默认‘‘
lines terminated by ‘string‘ 行结束符,默认为‘\n‘

ignore number lines  忽略输入文件中的前n行数据

实例

load data infile ‘/tmp/emp.txt‘ into table emp fields terminated by ‘,‘ enclosed by ‘"‘ ignore 2 lines;

只是加载部分列或者更改列的顺序

load data infile ‘/tmp/emp.txt‘ into table emp fields terminated by ‘,‘ enclosed by ‘"‘ ignore 2 lines (列名);

方法2:

mysqlimport 

mysqlimport -uroot -p [--LOCAL] dbname 文件文件  [option]

 

mysql的导入,布布扣,bubuko.com

热门排行

今日推荐

热门手游