Home  >  Article  >  Database  >  使用 load data 将格式化文件导入MySQL表

使用 load data 将格式化文件导入MySQL表

WBOY
WBOYOriginal
2016-06-07 17:11:19929browse

如果你登陆了远程的mysql服务器,然后,想把你本地的文本导入到数据库中的时候,需要local,命令不同以上

Load data的用法如下:

LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt'

    [REPLACE | IGNORE]

    ]

    [LINES

    ]

 

比如一个数据文本如下:

收盘价


LOAD DATA LOCAL INFILE 'table_name.txt'

INTO TABLE database_name

FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\'

LINES STARTING BY 'Def'

IGNORE 1 LINES

(stock_code,stock_name,opening,settlement);


下面看一下我的实际操作:


如果你登陆了远程的mysql服务器,,然后,想把你本地的文本导入到数据库中的时候,需要local,命令不同以上

load data local  infile '/usr/local/mysql/var/Statistic/Spam.txt' into table  Spam;

linux

Statement:
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