通過DOS命令將txt檔案匯入mysql資料庫

2022-08-02 14:48:14 字數 702 閱讀 8357

首先在資料庫中建立表結構

尤其注意字符集要和txt檔案編碼一致(這裡都是utf8),還要注意txt中的資料型別要和資料庫中列的資料型別保持一致,如果匯入時報錯

就可能是編碼不一致,可以就txt檔案 再次另存為,修改編碼

dos命令:

use demo

load data infile 'f:/industry2.txt' into table filedcode;

demo為資料庫名稱

f:/industry2.txt為需要匯入的txt檔案位址 

filedcode為表名

還要注意txt檔案中將第一行的表頭去掉。

最終結果:

通過sqlldr將txt檔案匯入oracle資料庫

有個專案每天要往資料庫裡插入大量的資料,峰值大概每秒一萬條左右。如果直接用insert語句,即使使用了批量也效果不是很理想。聽說從檔案匯入的方式效率很高,所以嘗試一下。建立乙個表 create table t 20200310 test phone varchar2 20 byte not null...

txt檔案匯入mysql

load data low priority concurrent local infile file name replace ignore into tabletbl name character setcharset name terminated by string optionally e...

txt檔案匯入mysql

mysql寫入資料通常用insert語句,如 c sharp view plain copy insert into person values 張三,20 李四,21 王五,70 但有時為了更快速地插入大批量資料或交換資料,需要從文字中匯入資料或匯出資料到文字。一 建立測試表,準備資料 首先建立乙...