mysql命令模式导出导入csv文件代码
发布:smiling 来源: PHP粉丝网 添加日期:2014-10-15 13:08:59 浏览: 评论:0
我们可以利用mysql 命令模式来导入或导出csv文件,有需要的朋友可以简单的参考一下,代码如下:
- mysql> select * from tt_address;
- +-----+-----+--------+--------+------+--------+------------+-------------+------
- -----+----------+-------+------------------------+-------+--------+-----+-------
- --+----------+------+---------+------+-----+--------+---------+-------+-----+---
- ------+-------------+--------------+---------------------------+----------------
- -------+
- | uid | pid | tstamp | hidden | name | gender | first_name | middle_name | last_
- name | birthday | title | email | phone | mobile | www | addres
- s | building | room | company | city | zip | region | country | image | fax | de
- leted | description | addressgroup | module_sys_dmail_category | module_sys_dmai
- l_html |
- +-----+-----+--------+--------+------+--------+------------+-------------+------
- -----+----------+-------+------------------------+-------+--------+-----+-------
- --+----------+------+---------+------+-----+--------+---------+-------+-----+---
- ------+-------------+--------------+---------------------------+----------------
- -------+
- | 2 | 42 | 0 | 1 | | m | aa | | aa
- | 0 | | tian.li@atop-online.de | | | |
- | d | | | | | | | | |
- 0 | | 0 | 0 |
- 0 |
- +-----+-----+--------+--------+------+--------+------------+-------------+------
- -----+----------+-------+------------------------+-------+--------+-----+-------
- --+----------+------+---------+------+-----+--------+---------+-------+-----+---
- ------+-------------+--------------+---------------------------+----------------
- -------+ --phpfensi.com
- 1 row in set (0.00 sec)
这个表里的只有一条数据,现在我导出的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 ---- 行终止符.
Tags: mysql命令模式 mysql导入csv
相关文章
- ·mysql 命令模式下导入.sql文件(2014-10-17)
- ·mysql命令模式修改mysql root密码笔记(2014-10-17)
- ·mysql采用命令行模式备份和还原数据(2015-04-17)
- ·Mysql导入csv数据的几种方法(2014-09-23)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)