First \COPY
isn't postgresql
. That's the client psql
. From the docs,
Do not confuse COPY with the psql instruction \copy. \copy invokes COPY FROM STDIN or COPY TO STDOUT, and then fetches/stores the data in a file accessible to the psql client. Thus, file accessibility and access rights depend on the client rather than the server when \copy is used.
No, psql does not provide filename completion. However there are other wrapper around COPY FROM STDIN
that are not psql
and they do. For instance pgloader
provides FROM [ ALL FILENAMES | [ FIRST ] FILENAME ] MATCHING
The same clause can also be applied to several files with using the spelling FROM ALL FILENAMES MATCHING and a regular expression. The whole matching clause must follow the following rule:
And on top of that you can always use bash or whatever shell you're using to launch psql. Example with bash filename expansion.
for i in *.csv;
do psql -c "\copy scheme.table FROM $$D:\path\to\$i.csv$$ DELIMITER ';' CSV ENCODING 'LATIN1';"
done;
Power-shell certainly also provides filename expansion. Google for it if you're on Windows 8+.