Mysql之outfile

1、outfile是将检索到的数据,保存到服务器的文件内:
格式:select * into outfile "文件地址"

示例:

mysql> select * into outfile 'f:/mysql/test/one' from teacher_class;

2、文件是自动创建的。

生成的文件格式:

默认的,采用行来区分记录,而采用tab制表符,来区分字段。

原始表:


生成后的表:


3、而为了满足某种特别的需求,会采用不同的分割方式。支持,在导出数据时,设置记录,与字段的分隔符。通过如下的选项:

fields:设置字段选项    Lines:设置行选项(记录选项)

字段:field terminated by '\t'

记录:lines terminated by '\n' starting by ''(每一行开始是空字符串);

select * into outfile 'f:/mysql/test/two' fields terminated by ',' lines terminated by '\n' starting by 'start:'  from teacher_class;

原始表:


生成文件后的表



也可以设置字段被特殊符号包裹:

select * into outfile 'f:/mysql/test/third' fields terminated by ',' enclosed by 'x' lines terminated by '\n' starting by 'start:'  from teacher_class;



注:常规的,所有的记录,应该通过行来显示,例外是保存二进制数据:

Blob binary

使用into dumpfile

 select * into dumpfile 'f:/mysql/test/six' from teacher_class limit 1;

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Henry_Jing

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值