mysql load data infile
ÈçºÎÌá¸ßmysql load
data
infile
µÄËÙ¶È
²âÊÔÊý¾Ý2.5G£¬¹²ÓÐÊý¾Ý9427567Ìõ¡£ÓõÄmysqlµÄlarge·þÎñÆ÷µÄÅäÖá£
load
Ò»´ÎÐèÒª´ó¸Å10·ÖÖÓ×óÓÒ¡£
½¨µÄ±íÓõÄÊÇMYISAM£¬µ÷ÕûÁ˼¸¸ösessionµÄ²ÎÊýÖµ
SET SESSION BULK_INSERT_BUFFER_SIZE=256217728;
SET SESSION MYISAM_SORT_BUFFER_SIZE=256217728;
ÔËÐнá¹ûÈçÏÂ
Query OK, 9427567 rows affected, 1558 warnings (3 min 55.21 sec)
Records: 9427567 Deleted: 0 Skipped: 0 Warnings: 0
googleµ½µÄ»¹¿ÉÒÔ
set global KEY_BUFFER_SIZE=256217728;
alter table tablename disable keys;
ÈçºÎload
Êý¾ÝÀïÃæ´ø·´Ð±¸Ü(backslash)”\” µÄÊý¾Ý
ÓÉÓÚÈç¹ûÄãûÓÐÖ¸¶¨FIELDS×Ӿ䣬ÔòĬÈÏֵΪ¼ÙÉèÄúдÏÂÈçÏÂÓï¾äʱµÄÖµ£º
FIELDS TERMINATED BY ‘\t’ ENCLOSED BY ” ESCAPED BY ‘\\’
ËùÒÔ£¬Èç¹ûÄãµÄÊý¾ÝÀïÃæÓз´Ð±¸Ü(backslash)”\”µÄʱºò£¬Êý¾Ý»á³öÏÖ±»½Ø¶ÏµÄÎÊÌâ¡£³öÏÖÕâÖÖÎÊÌ⣬ֻҪдÉÏÈçϵÄfields×Ӿ伴¿É
FIELDS TERMINATED BY ‘\t’ ENCLOSED BY ” ESCAPED BY ”
ÈçºÎload
µÄʱºòÖ»insertÌض¨µÄÁÐ
±ÈÈç±íÀïÃæÓбÈÔªÊý¾Ý¶àµÄÁС£¿ÉÒÔÔÚload
µÄʱºòÖ¸¶¨Òª²åÈëµÄ×Ö¶ÎÃû×Ö¡£
ʾÀýµÄ´úÂëÈçÏ£º
LOAD
DATA
INFILE
'
~/data.txt
'
INTO
TABLE
fb0505
CHARACTER
SET
gbk
FIELDS
TERMINATED
BY
'
\t
'
ENCLOSED
BY
''
ESCAPED
BY
''
LINES
TERMINATED
BY
'
\n
'
STARTING
BY
''
(
seller_id
,
fb_type
,
fb_date
,
item_url
)
;
ÆäÖбífb0505ÀïÃ滹ÓÐÒ»ÁÐÊÇid¡£
Ïà¹ØÎĵµ£º
½â¾öÂÒÂë×îºÃµÄ·½·¨ÊÇÔÚÏîÄ¿Éè¼ÆÖ®³õ£¬Í³Ò»ËùÓеÄ×Ö·û¼¯£¬ÀýÈçÒ³Ãæ¡¢request¶ÔÏóÒÔ¼°Êý¾Ý¿âµÈµÈ¡£
Ò»¡¢ ¼¸ÖÖ³£¼ûµÄÂÒÂëÏÖÏó£º
1¡¢Ò³ÃæÂÒÂë
µ¥´¿µÄÒ³ÃæÂÒÂëÊǺܺýâ¾öµÄ£¬Ö»ÒªÐÞ¸ÄÍ·²¿ÊʺϵÄ×Ö·û¼¯¼´¿É£¬Èç¹ûÒ³ÃæÖÐÎÄÏÔʾÂÒÂ룬Äã¿ÉÒÔ°Ñ×Ö·û¼¯ÐÞ¸ÄΪ£ºgb2312»ògbk¡£
2¡¢Ò³ÃæÖ®¼ä´«µÝµÄ²ÎÊýÊÇÂÒÂë ......
[root@sql21 ~]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 5.1.26-rc-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database &nb ......
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySQLDriverCS;
&nb ......
MysqlÊý¾Ý¿âÌṩÁ½ÖÖÀàÐ͵ÄË÷Òý£¬Èç¹ûûÕýÈ·ÉèÖã¬Ë÷ÒýµÄÀûÓÃЧÂÊ»á´ó´òÕÛ¿ÛÈ´ÍêÈ«²»ÖªÎÊÌâ³öÔÚÕâ¡£
CREATE TABLE test (
id INT NOT NULL,
last_name CHAR(30) NOT NULL,
first_name CHAR(30) NOT NULL,
PRIMARY KEY (id),
INDEX name (last_name,first_name)
);
ÒÔÉÏ´ ......
WordpressÓÃÁËÕâô³¤Ê±¼ä£¬Å¼¶û»áÏëÆðÀ´±¸·ÝÏÂÊý¾Ý£¬ÉÏ´ÎÊÇÓÃwpµÄxml£¬Õâ´Î°Ñ×Ô¼º»úÆ÷µÄ»·¾³ÅäµÄ¸úÖ÷»úÌṩÉÌ»ù±¾Ò»ÑùÁË£¬ÕýºÃÄDZßÓÐmysqlÊý¾Ý¿â´ò°ü±¸·ÝµÄ·þÎñ£¬¾Í³¢ÊÔÁËһϡ£¿É²»¹ÜÎÒÏÂÔØÄĸöʱ¼äµãµÄ±¸·Ý°ü£¬ÀïÃ涼ֻÓÐwp±íµÄ10¸öfrmÎļþ£¬copyµ½ÎÒµÄÊý¾Ý¿âĿ¼ºó·ÃÎÊweb£¬Ã»ÓÐÈκÎÊý¾Ý£¡Ö±½Ó¸ã²»¶®ÁË¡£ÒÔÇ°¾õµÃÓÃmysql ......