Home > Database > Mysql Tutorial > MYsql数据文本形式导出与导入_MySQL

MYsql数据文本形式导出与导入_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:32:30
Original
982 people have browsed it

bitsCN.com

MYsql数据文本形式导出与导入

 

一、查询表结构

mysql> desc province;

+-----------+-------------+------+-----+---------+----------------+

| Field     | Type        | Null | Key | Default | Extra          |

+-----------+-------------+------+-----+---------+----------------+

| id        | int(11)     | NO   | PRI | NULL    | auto_increment |

| name      | varchar(32) | NO   |     | NULL    |                |

| countryId | int(11)     | YES  | MUL | NULL    |                |

+-----------+-------------+------+-----+---------+----------------+

二、表中数据导出为文本文件(.txt)

Sql代码  

select id,name,countryId  

into outfile"d:/data_out.txt"  

lines terminated by "/r/n"  

from province;  

 导出结果:

1    北京    1

2    上海    1

3    天津    1

4    重庆    1

5    黑龙江    1

6    吉林    1

7    辽宁    1

……

三、文本文件导入数据库

Sql代码  

load data local infile "d:/data_out.txt"  

into table t_province(id,name);  

 导入结果:

mysql> select * from t_province;

+----+--------+

| id | name   |

+----+--------+

|  1 | 北京   |

|  2 | 上海   |

|  3 | 天津   |

|  4 | 重庆   |

|  5 | 黑龙江 |

 

bitsCN.com
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template