从文本文件导入数据到数据库表

版权声明:本文为博主原创文章,转载还请注明出处。 https://blog.csdn.net/lvshuangtao/article/details/51721503

最近一直在使用常用数据库的数据导入,这里把已经用到的导入命令先简要列举一下:

SQL Server数据导入

不介绍每一个option的具体意义,如果你用到了,请直接MSDN查看具体option的意义,此处不再赘述!

BULK INSERT [erp].[USERS]
FROM 'D:\rows_1m.txt'
   WITH (
      DATAFILETYPE='widechar',
      FIELDTERMINATOR =',',
      ROWTERMINATOR = '\n'
);
GO

MySQL数据导入

LOAD DATA INFILE '/home/test/users_1m_rows.txt' INTO TABLE DUMMY_USERS FIELDS TERMINATED BY ','  LINES TERMINATED BY '\n' (COL00,COL01,COL02,COL03,COL04,COL05,COL06,COL07,COL08,COL09,COL10,COL11,COL12,COL13,COL14,COL15,COL16,COL17,COL18,COL19,COL20,COL21,COL22,COL23,COL24,COL25,COL26,COL27,COL28,COL29,COL30,COL31);

不赘述option的意义了。

PostgreSQL数据导入

\copy "USERS"("COL00","COL01","COL02","COL03","COL04","COL05","COL06","COL07","COL08","COL09","COL10","COL11","COL12","COL13","COL14","COL15","COL16","COL17","COL18","COL19","COL20","COL21","COL22","COL23","COL24","COL25","COL26","COL27","COL28","COL29","COL30","COL31") FROM '/home/test/pg_1m.txt'  DELIMITER '|'  ENCODING 'utf-8'

同样也不介绍具体的option的意义,大部分都是self-explain的。

Oracle

To be added

阅读更多

没有更多推荐了,返回首页