PostgreSQL: Can DBeaver emulate "COPY" from "stdin"?
See original GitHub issuePostgreSQL’s COPY
command allows to copy data from stdin
, the standard input, to a table; and vice-versa. That way, you can do this:
COPY students FROM stdin;
1 Denholm Gladwin 33
2 Becka Morris 31
3 Flora Kingston 27
\.
Which is more compact than this, and maybe more readable:
INSERT INTO students
VALUES
(1, 'Denholm', 'Gladwin', 33),
(2, 'Becka', 'Morris', 31),
(3, 'Flora', 'Kingston', 27);
This works well when you run the query from the command line, using the psql
command. But obviously, DBeaver fails to do so because it tries to parse the data as separate statements.
I know that you can put the data into an external file (i.e. a CSV file) and load it using COPY
. But, if the server is in another machine, the file will be unreachable; because the command is run on the server-side, not in the client-side.
But, even if the server is run locally, the path to the data file won’t be portable. Because the path is relative to the server’s cluster directory, not the script location. In other words: you need an absolute path.
I also know that I can use the feature of DBeaver to import data. But I’m using COPY
because I’m preparing and testing SQL scripts that will be run in other machines, by other users, in a semi-automated way.
This is not a vital feature, of course. I can rely on INSERT
for this task. But I would like to know whether DBeaver can emulate the stdin
or not.
Thank you!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (4 by maintainers)
This function will be added in future releases
The first beta version is ready. DBeaver creates a PG-specific CSV file and loads it using
COPY INTO STDIN
. This feature works only for PostgreSQL, Greenplum, EDB, and Cockroach.