English 中文(简体)
从 pgplsql 提供的 COPY
原标题:COPY FROM in pgplsql
  • 时间:2012-05-24 17:20:27
  •  标签:
  • postgresql

我试图在 pgplsql 函数中运行下面的语句, 并收到错误信息“ 格式% 2f 无效或与参数不符” 。

copy raw_import from  c:\files\test.csv  CSV;

如果我直接作为剧本运行,它就会像预想的那样有效,所以我删除了测试.csv 的内容,就像问题一样。我还尝试用“执行”语句来包装它,并获得同样的结果。

execute  copy raw_import from   c:\files\test.csv   CSV ;

我最近才开始发邮件 所以我怀疑我缺少一些基本的想法 任何想法都会感激不尽

Requested sample of file - first 3 records: a,b,c,d e,f,g,h i,j,k,l

Table definition: col1 VARCHAR(100), col2 VARCHAR(100), col3 VARCHAR(100), col4 VARCHAR(100)

最佳回答

检查客户端和服务器编码 :

cpn=> show server_encoding;
 server_encoding 
-----------------
 UTF8
(1 row)

cpn=> show client_encoding;
 client_encoding 
-----------------
 UTF8
(1 row)

如果他们不匹配, 它可以解释为什么它作为脚本运行, 而当您在服务器运行时不运行, 也就是说, 文件编码错误 。

问题回答

暂无回答




相关问题
摘录数据

我如何将Excel板的数据输入我的Django应用? I m将PosgreSQL数据库作为数据库。

Postgres dump of only parts of tables for a dev snapshot

On production our database is a few hundred gigabytes in size. For development and testing, we need to create snapshots of this database that are functionally equivalent, but which are only 10 or 20 ...

How to join attributes in sql select statement?

I want to join few attributes in select statement as one for example select id, (name + + surname + + age) as info from users this doesn t work, how to do it? I m using postgreSQL.

What text encoding to use?

I need to setup my PostgreSQL DB s text encoding to handle non-American English characters that you d find showing up in languages such as German, Spanish, and French. What character encoding should ...

SQL LIKE condition to check for integer?

I am using a set of SQL LIKE conditions to go through the alphabet and list all items beginning with the appropriate letter, e.g. to get all books where the title starts with the letter "A": SELECT * ...

热门标签