ERROR: syntax error at or near "\"
LINE 1: \copy mytable FROM urishFile WITH (FORMAT csv, DELIMITER ','...
^
从 c++ 程序运行命令时出现此错误。
command = "\\copy mytable FROM urishFile WITH (FORMAT csv, DELIMITER ',', NULL 'NULL');";
executCommand(conn, command);
void executCommand(PGconn *conn, std::string command) {
PGresult *res; // holds query result
res = PQexec(conn, command.c_str());
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
fprintf(stderr, "%s", PQerrorMessage(conn));
PQclear(res);
exit_nicely(conn);
}
PQclear(res);
}
从 psql 提示符运行相同的命令时,它可以正常工作。
mydatabase=> \copy mytable FROM urishFile WITH (FORMAT csv, DELIMITER ',', NULL 'NULL');
我做错了什么?