北京SEO

mysql命令模式导出导入csv文件代码

2019/10/10/17:33:05  阅读:1679  来源:谷歌SEO算法  标签: SEO博客

我们可以利用mysql 命令模式来导入或导出csv文件,有需要的朋友可以简单的参考一下,代码如下:

  1. mysql>select*fromtt_address;
  2. +-----+-----+--------+--------+------+--------+------------+-------------+------
  3. -----+----------+-------+------------------------+-------+--------+-----+-------
  4. --+----------+------+---------+------+-----+--------+---------+-------+-----+---
  5. ------+-------------+--------------+---------------------------+----------------
  6. -------+
  7. |uid|pid|tstamp|hidden|name|gender|first_name|middle_name|last_
  8. name|birthday|title|email|phone|mobile|www|addres
  9. s|building|room|company|city|zip|region|country|image|fax|de
  10. leted|description|addressgroup|module_sys_dmail_category|module_sys_dmai
  11. l_html|
  12. +-----+-----+--------+--------+------+--------+------------+-------------+------
  13. -----+----------+-------+------------------------+-------+--------+-----+-------
  14. --+----------+------+---------+------+-----+--------+---------+-------+-----+---
  15. ------+-------------+--------------+---------------------------+----------------
  16. -------+
  17. |2|42|0|1||m|aa||aa
  18. |0||tian.li@atop-online.de||||
  19. |d|||||||||
  20. 0||0|0|
  21. 0|
  22. +-----+-----+--------+--------+------+--------+------------+-------------+------
  23. -----+----------+-------+------------------------+-------+--------+-----+-------
  24. --+----------+------+---------+------+-----+--------+---------+-------+-----+---
  25. ------+-------------+--------------+---------------------------+----------------
  26. -------+--phpfensi.com
  27. 1rowinset(0.00sec)

这个表里的只有一条数据,现在我导出的csv文件里只需要有uid,name,gender,email,module_sys_dmail_html.命令行如下:select uid,name,gender,email,module_sys_dmail_html into outfile 'd:\test7.csv' fields terminated by ',' optionally enclosed by '"' lines terminated by 'n' from tt_address

cvs文件导入MySql数据库命令:

mysql> load data local infile 'e:\input1.csv' into table test1 fields terminated by ','lines terminated by 'n'(first_name,last_name,email);

FIELDS TERMINATED BY ---- 字段终止字符.

FIELDS OPTIONALLY ENCLOSED BY ---- 封套符.

LINES TERMINATED BY ---- 行终止符.

广告内容

mysql命令模式导出导入csv文件代码 mysql命令模式导出导入csv文件代码 mysql命令模式导出导入csv文件代码

相关阅读

热门评论

萧红SEO 萧红SEO

SEO爱好者,分享SEO经验~

总篇数212

精选文章

Mysql数据库错误代码中文说明详解 php+mysql+session登录实例程序代码 MySQL选择数据库use与mysql_select_db使用详解 mysqldump数据备份与还原详细介绍 GitHub用户发起HTML5网页移植版《星际争霸》项目 mysql创建和删除索引的笔记 wdcp安装apache安装mod_proxy代理模块 Linux操作系统RPM与TAR的基本安装和卸载 mysql InnoDB数据无法启动解决办法 批量删除阿里云OSS Object的脚本

SEO最新算法