Get the count of rows from a COPY command

前端 未结 1 919
梦毁少年i
梦毁少年i 2021-01-05 12:58

When copying data from a file, you get the count of rows in psql with the \"command tag\":

db=# COPY t FROM \'/var/lib/postgres/test.sql\';
COPY 10

        
相关标签:
1条回答
  • 2021-01-05 13:21

    Not in PG 9.2, but there is in PG 9.3 courtesy of Pavel (E 1.3.1.7):

    Allow PL/pgSQL to access the number of rows processed by COPY (Pavel Stehule)

    The command is GET DIAGNOSTICS x = ROW_COUNT.

    http://www.postgresql.org/docs/devel/static/release-9-3.html

    0 讨论(0)
提交回复
热议问题