PG_LAST_COPY_COUNT - Amazon Redshift
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

PG_LAST_COPY_COUNT

Returns the number of rows that were loaded by the last COPY command run in the current session. PG_LAST_COPY_COUNT is updated with the last COPY ID, which is the query ID of the last COPY that began the load process, even if the load failed. The query ID and COPY ID are updated when the COPY command begins the load process.

If the COPY fails because of a syntax error or because of insufficient privileges, the COPY ID is not updated and PG_LAST_COPY_COUNT returns the count for the previous COPY. If no COPY commands were run in the current session, or if the last COPY failed during loading, PG_LAST_COPY_COUNT returns 0. For more information, see PG_LAST_COPY_ID.

Syntax

pg_last_copy_count()

Return type

Returns BIGINT.

Example

The following query returns the number of rows loaded by the latest COPY command in the current session.

select pg_last_copy_count(); pg_last_copy_count -------------------- 192497 (1 row)