记录几个PostgreSQL SQL语句遇到的小坑

1. PostgreSQL SQL执行 提示UTF8 什么出错.   最后查到  有保存路径  E:\\xxx\x\   修改为E:\\\\xxx\\x\\   就OK了

2. PostgreSQL SQL  Copy 语法. 

COPY tablename [ ( column [, ...] ) ] FROM { 'filename' | STDIN } [ [ WITH ] [ BINARY ] [ OIDS ] [ DELIMITER [ AS ] 'delimiter' ] [ NULL [ AS ] 'null string' ] [ CSV [ QUOTE [ AS ] 'quote' ] [ ESCAPE [ AS ] 'escape' ] [ FORCE NOT NULL column [, ...] ] COPY tablename [ ( column [, ...] ) ] TO { 'filename' | STDOUT } [ [ WITH ] [ BINARY ] [ OIDS ] [ DELIMITER [ AS ] 'delimiter' ] [ NULL [ AS ] 'null string' ] [ CSV [ QUOTE [ AS ] 'quote' ] [ ESCAPE [ AS ] 'escape' ] [ FORCE QUOTEcolumn [, ...] ]

1. Copy 本地服务器 或是导出为服务器上的文件

   COPY table( column1,column2 )   FROM '文件路径' DELIMITER '#' ;

2. Copy 服务器 或是导出为客户端的文件

   COPY table( column1,column2 )   FROM STDIN  然后用下方方法批量导入数据 

关于copy 查看这个连接http://www.npgsql.org/doc/copy.html

using (var writer = conn.BeginTextImport("COPY data (field_text, field_int4) FROM STDIN")) {
    writer.Write("HELLO\t1\n");
    writer.Write("GOODBYE\t2\n");
}

using (var reader = conn.BeginTextExport("COPY data (field_text, field_int4) TO STDOUT")) {
    Console.WriteLine(reader.ReadLine());
    Console.WriteLine(reader.ReadLine());
}

3. 此方法提示 超过数据超过结尾..

 后面发现是最后一个多了\t  应该是\N 

你可能感兴趣的:(SQL学习笔记,Net开发)