請教如何把txt檔案匯入到mysql裡面
來源:互聯網
上載者:User
請問怎麼把txt檔案匯入到mysql裡面
請問怎麼把txt檔案匯入到mysql裡面,這個txt檔案是從別人網站上匯出來的,格式固定,是以空格為分割符的,以下是txt檔案部分內容:
order-idorder-item-idpurchase-datepayments-datereporting-datepromise-datedays-past-promisebuyer-emailbuyer-namebuyer-phone-numberskuproduct-namequantity-purchasedquantity-shippedquantity-to-shipship-service-levelrecipient-nameship-address-1ship-address-2ship-address-3ship-cityship-stateship-postal-codeship-country
503-5296313-1551031675260543927982012-06-19T06:09:33+00:002012-06-19T06:09:33+00:002012-06-19T06:40:09+00:002012-06-21T14:59:59+00:003[email protected]嫿揷媑岶09021971453GV0123-Gevey_Pro-37SaiPhone4懳墳 SIM儘僢僋夝彍傾僟僾僞 iOS4.21摦嶌妋擣嵪傒101Standard嫿揷媑岶恄屗巗悅悈嬫懡暦挰868-812丂巐恄價儖2F暫屔導655-0001JP
249-8506878-4596622090045092606222012-06-19T12:29:37+00:002012-06-19T12:29:37+00:002012-06-
------解決方案--------------------
用php嗎?
上面第一行是資料庫的欄位 下面的是資料 所以根據這個格式讀成數組 再拼裝成SQL語句 執行...
------解決方案--------------------
先建立表。然後在命令列下執行:
load data local infile “c:/data.txt”
into table tt ;
記住不要把路徑搞錯了。