mysql load file

当你与LOAD DATA INFILE一起使用SELECT ... INTO OUTFILE将一个数据库的数据写进一个文件并且随后马上将文件读回数据库时,两个命令的字段和处理选项必须匹配,否则,LOAD DATA INFILE将不能正确解释文件的内容。假定你使用SELECT ... INTO OUTFILE将由逗号分隔的字段写入一个文件:

mysql> SELECT * FROM table1 INTO OUTFILE ‘data.txt‘
           FIELDS TERMINATED BY ‘,‘
           FROM ...

为了将由逗号分隔的文件读回来,正确的语句将是:

mysql> LOAD DATA INFILE ‘data.txt‘ INTO TABLE table2
           FIELDS TERMINATED BY ‘,‘;

相反,如果你试图用下面显示的语句读取文件,它不会工作,因为它命令LOAD DATA INFILE在字段之间寻找定位符:

mysql> LOAD DATA INFILE ‘data.txt‘ INTO TABLE table2
           FIELDS TERMINATED BY ‘\t‘;

可能的结果是每个输入行将被解释为单个的字段。

LOAD DATA INFILE能被用来读取从外部来源获得的文件。例如,以dBASE格式的文件将有由逗号分隔并用双引号包围的字段。如果文件中的行由换行符终止,下面显示的命令说明你将用来装载文件的字段和行处理选项:

mysql> LOAD DATA INFILE ‘data.txt‘ INTO TABLE tbl_name
           FIELDS TERMINATED BY ‘,‘ ENCLOSED BY ‘"‘
           LINES TERMINATED BY ‘\n‘;

任何字段或行处理选项可以指定一个空字符串(‘‘)。如果不是空,FIELDS [OPTIONALLY] ENCLOSED BY和FIELDS ESCAPED BY值必须是一个单个字符。FIELDS TERMINATED BY和LINES TERMINATED BY值可以是超过一个字符。例如,写入由回车换行符对(CR+LF)终止的行,或读取包含这样行的一个文件,指定一个LINES TERMINATED BY ‘\r\n‘子句。

比如:load data infile ‘data.txt‘ into table user_info fields  terminated by ‘#‘ enclosed by "" lines terminated by ‘\r\n‘;

时间: 2024-09-27 04:35:16

mysql load file的相关文章

Could not load file or assembly 'MySql.Data.CF,

Could not load file or assembly 'MySql.Data.CF, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047 I so

【架构】How To Use HAProxy to Set Up MySQL Load Balancing

How To Use HAProxy to Set Up MySQL Load Balancing Dec  2, 2013 MySQL, Scaling, Server Optimization Ubuntu, Debian Prelude HAProxy is an open source software which can load balance HTTP and TCP servers. In the previous article on HAProxy we configured

mysql load data infile的使用 和 SELECT into outfile备份数据库数据

LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt' [REPLACE | IGNORE] INTO TABLE tbl_name [FIELDS [TERMINATED BY 'string'] [[OPTIONALLY] ENCLOSED BY 'char'] [ESCAPED BY 'char' ] ] [LINES [STARTING BY 'string'] [TERMINATED BY 'string

[转] ASP.NET WEB API程序在VS启动或发布到IIS后启动后发生 - Could not load file or assembly 'System.Web.Http.WebHost’异常,无法正常访问

Just do Copy Local = true in the properties for the assembly(System.Web.Http.WebHost) and then do a redeploy, it should work fine. http://stackoverflow.com/questions/20323107/could-not-load-file-or-assembly-system-web-http-webhost-after-published-to-

Could not load file or assembly 'System.Core, Version=2.0.5.0 和autofac冲突的问题

在部署到iis的时候会出现这个状况.   这个软件(NDP40-KB2468871-v2-x64) 解决:下载安装这个补丁 http://support.microsoft.com/kb/2468871 http://www.microsoft.com/zh-cn/download/confirmation.aspx?id=3556 http://download.microsoft.com/download/2/B/F/2BF4D7D1-E781-4EE0-9E4F-FDD44A2F8934/

Could not load file using Ranorex runtime : General Questions

如果你将编译好的bin文件夹复制到另一个未安装Ranorex程序的电脑上运行遇到如下错误信息 Could not load file or assembly 'Ranorex.Core, Version=2.3.3.8879, Culture=neutral, PublicKeyToken=b798506b574ebc9a' or one of its dependencies. The system cannot find the file specified 说明未找到Ranorex.Cor

错误处理:"Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format."

情况:部署程序在 IIS 7.5 windows server 2008 R2 64 bit OS,引用“Oracle.DataAccess.dll” 运行程序会出现:"Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format." 解决方式:设置IIS  app

System.BadImageFormatException: Could not load file or assembly

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>InstallUtil.exe C:\_PRODUKCIJA\Debug\DynamicHtmlTool.exeMicrosoft(R).NET FrameworkInstallation utility Version4.0.30319.1Copyright(c)MicrosoftCorporation.  All rights reserved.Exception occurred while i

[Nuget] - "Runtime error: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0'" 问题之解决

环境 项目中使用了 System.Web.WebPages.Razor, Version=3.0.0.0,Nuget 还原缺失包后自动更新至 Version=3.2.5.0,编译成功,运行失败. 错误 "/"应用程序中的服务器错误.未能加载文件或程序集"System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"或它的某一个依赖项.系统找不到