关于TXT文件导入MYSQL问题
主要情况如下:
现有一文本数据文件,里面的数据如下:
abc 123
def 223 2 wwww
uuu 456 5 xxx
……
数据有几w条 一行最多4列 但是3,4两行可能没有,为空格
关于这个文件,我怎么导入,请高手指点,请尽量详细说明。
PS:load data infile 我研究过 没有此类语法 列设置缺省也没用
讲文件导入txt文本
查找替换 空格为 /N
load data local infile
SQL code:
mysql> load data local infile 'D:\\csdn.txt' into table t
-> fields terminated by ' '
-> lines terminated by '\r';
Query OK, 4 rows affected, 2 warnings (0.03 sec)
Records: 4 Deleted: 0 Skipped: 0 Warnings: 1
mysql> select * from t;
+---------+------+------+--------+
| name | num | type | net |
+---------+------+------+--------+
| abc | 123 | 0 | NULL |
|
dee | 223 | 2 | www |
|
uuu | 456 | 5 | xxx |
|
uudkdu | 456 | 5 | xxxxxx |
+---------+------+------+--------+
4 rows in set (0.00 sec)
直接用load data infile就可以处理了。估计你上面主要处理好你的列分隔符就应该可以了:
SQL code:
load data local infile '文件路径' into table 表名 fiel
相关问答:
如题,这三个在win7下使用会有什么兼容性问题吗?
由于我最近在使用win7,就懒得进xp了!
自己用windows 2008有一年多了,没出现任何问题。
win7测试版也用过,不会有什么问题的,放心。
当然你最 ......
大家好,我在创建索引时,出现错误提示,代码如下:
create uique index stu_cou_index on student_info.results (student_id, course_id);
show index from student_info.results;
保存为index.s ......
MySql中插入当前时间的该怎么写啊?
now()
SQL code:
sql里是:
getdate()
引用
now()
学习
SQL code:
select now();
SQL code:
TODAY()
?
SQL code:
select now();
/* ......
日IP数千 以后会上万 也是flex+java游戏类型的网站 集中在高峰期晚上
请问数据库服务器的机器用什么品牌好?推荐一个配置?
现在数据库是使用mysql5.0 是不是适合? 该不该换成Oralce(现在换还 ......
import java.sql.*;
public class A
{
public static void main(String[] args)
{
try
{
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost ......