請教如何把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 ;

記住不要把路徑搞錯了。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.