CURRENT_LOAD_SOURCE

Returns the file name used during the COPY statement.

Behavior Type

Stable

Syntax

CURRENT_LOAD_SOURCE()

Behavior

Examples

This example creates a table and populates column c3 with the names of the two separate files being loaded.

=> CREATE TABLE t (c1 integer, c2 varchar(50), c3 varchar(200));
CREATE TABLE
=> COPY t (c1, c2, c3 AS CURRENT_LOAD_SOURCE()) FROM '/home/load_file_1' ON exampledb_node02, '/home/load_file_2' ON exampledb_node03 DELIMITER ',';
Rows Loaded
-------------
5
(1 row)
=> SELECT * FROM t;
c1  |      c2      |          c3
----+--------------+-----------------------
2   |  dogs        | load_file_1
1   |  cats        | load_file_1
4   |  superheroes | load_file_2
3   |  birds       | load_file_1
5   |  whales      | load_file_2
(5 rows)

See Also