copy使用 copy t from '/home/teledb/t.txt' (format 'binary'); COPY 4 teledb select from t; id name birth city +++ 1 张三 20001201 00:00:00 北京 2 李四 19970324 00:00:00 上海 3 王五 20040901 00:00:00 广州 4 赵六 20001201 00:00:00 (4 rows) 使用delimiter指定列与列之间的分隔符 teledb ! cat /home/teledb/t.txt 1%张三%20001201 00:00:00%北京 2%李四%19970324 00:00:00%上海 3%王五%20040901 00:00:00%广州 4%赵六%20001201 00:00:00%N teledb truncate table t; TRUNCATE TABLE teledb copy t from '/home/teledb/t.txt' (format 'text', delimiter '%'); COPY 4 NULL值处理 teledb truncate table t; TRUNCATE TABLE teledb ! cat /home/teledb/t.txt 1,张三,20001201 00:00:00,北京 2,李四,19970324 00:00:00,上海 3,王五,20040901 00:00:00,广州 4,赵六,20001201 00:00:00,NULL teledb copy t from '/home/teledb/t.txt' (format 'csv', null 'NULL'); COPY 4 teledb select from t; id name birth city +++ 1 张三 20001201 00:00:00 北京 2 李四 19970324 00:00:00 上海 3 王五 20040901 00:00:00 广州 4 赵六 20001201 00:00:00 (4 rows) 将文件中的NULL字符串当成NULL值处理,SQL Server导出来的文件中把NULL值替换成字符串NULL,所以入库时可以这样处理一下,注意字符串是区分大小写 自定义quote 字符 teledb