Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [copy]

The tag has no usage guidance.

0
votes
2answers
38 views

Copying all columns of a row from table into another?

I would like to keep the history of a table using SQL queries without triggers. The simplest way to do that is to fire a SELECT and INSERT into the history table like below: INSERT INTO history (...
1
vote
1answer
42 views

How to copy selected table data from sql server to mysql on a daily basis? [closed]

I am having a retail pos application with MSSQL database. Now I need to transfer selected table data from SQL server to MYSQL database on a daily basis like job. How to achive this?
0
votes
0answers
22 views

Skip row if Postgres COPY command can not validate syntax of an import file column

I know that it is possible to use null parameter to convert empty strings when getting errors like: invalid input syntax for integer: "0A" by using COPY my_table FROM '/my/file.csv' (FORMAT csv, ...
-2
votes
1answer
130 views

Using Postgres \COPY function with TSV format

I am getting ERROR: COPY format "tsv" not recognized when trying to copy file contents with psql \copy function. For some reason Postgres does not know TSV format? Command that I am running is: psql -...
1
vote
1answer
49 views

Implications of using PostgreSQL COPY command to stdout and then immeadiately reading it from stdin

When transferring data between two databases, I would like to know if there is any disadvantages in the following approach: psql -h [HOST1] -U postgres -d [DB1] -c [SQL1] | psql -h [HOST2] -d [DB2] -...
0
votes
1answer
44 views

With PostgreSQL getting ERROR: COPY format “CSV” not recognized

Whever I try to copy from test=# \COPY table FROM 'file.csv' WITH ( FORMAT 'CSV', HEADER true ); ERROR: COPY format "CSV" not recognized What's the reason for this? I know I've used this before.
2
votes
0answers
38 views

Copy to file and transform arrays

I'm copying data from a Postgres DB on AWS RDS to a Postgres-like DB on AWS Redshift. Varchar arrays are being exported as {foo,bar} but Redshift wants them as ["foo","bar"]. Redshift doesn't ...
0
votes
1answer
265 views

MySQL copy all views from one database to another in stored procedure

I've got a stored procedure that copies all tables from one database to another but steps through each table individually (because of queries). I need to add to the stored procedure to copy all views ...
1
vote
0answers
207 views

Postgres pg_dump copy table to another database isn't copying columns

Goal: copy a single table including all columns from one database to another using psql on the command line, avoiding an issue with XML from QGIS layer styles. I am running the following on the ...
2
votes
1answer
181 views

postgresql - Importing CSV Data with Custom Type

I'm mostly a newcomer to databases and am building a postgres database of student achievement in a series of courses. My database uses a type called "class" that consists of the course, the academic ...
0
votes
1answer
27 views

Oracle 11g database copy

I got database oracle 11g on my localhost on laptop. I would like to copy it to run on other PC (windows) for some tests. How can I do that?
1
vote
1answer
238 views

How can I import CSV data stored in a bytea?

I have a CSV file that can be loaded into a table easily with COPY FROM, but the catch is that the file is stored in the database in a bytea field. Is the only way to use COPY on this data to write ...
0
votes
1answer
50 views

How can clone database in mariadb prompt character?

mysqlword="wwww" old="xxxx" new="yyyy" mysqldump $old -u root -p$mysqlword | mysql $new -u root -p$mysqlword Now new database was cloned as like old database. Can i use some command to clone ...
3
votes
2answers
83 views

SQL Server 2016 Primary and Backup

We have a new production box with two SQL servers,SQL Server 2016 Standard edition. The current plan is to have: One primary SQL server Backup SQL server:only SQL Report server,which points to ...
1
vote
1answer
90 views

How do I synchronize parallel imports with COPY? [closed]

I have ~20 tables that get built at the same time but using different psql processes (via bash script) at the first stage with something like: create table foo_1 as (select ....); -- via psql process ...
1
vote
0answers
162 views

Export json data into single cell

My problem is a relatively simple one; unfortunately, I haven't been able to find any solutions from searching around. I have a SQL table called alerts from which I'm trying to export data into CSV ...
0
votes
2answers
36 views

INSERT statement COPY equivalent [closed]

I would like to transform this: INSERT INTO users (username) VALUES ('JohnDoe'); Into a copy equivalent: COPY users (username) FROM ('JohnDoe'); What would be a correct syntax for the copy ...
2
votes
1answer
464 views

Can I trim values on COPY from csv?

I used csvsql to generate CREATE statements, and it looks like it assumed trimmed fields though the data has some spaces padding the field: ERROR: value too long for type character varying(11) ...
0
votes
1answer
329 views

How output a json file in postgresql functions?

I want to define a trigger in postgresql when updated a record in a db table, It output the record as a json file: CREATE TABLE mytable( id serial primary key, first_name varchar(40) NOT NULL, ...
1
vote
2answers
752 views

How do I use a dynamic command with copy from program?

I'm trying to read a JSON API with the Postgres copy from program command. When I call copy _temp from program 'curl -uri "https://url"'; it works fine but the API has paging and I need to loop ...
1
vote
1answer
1k views

COPY FROM STDIN from client app

I have a client appconsole. I want to execute a SQL command "copy from stdin" and send data from client STDIN to Postgres server to fill a table. Is it possible without psqlclient and just via ...
0
votes
1answer
408 views

Splitting a csv bulk import to postgres into smaller blocks using psycopg2

I have a number of csv-files that I would like to import into my postgres-database. Since each file is quite large (200m-2bn records/file) I believe it would be better to add each file in smaller ...
2
votes
3answers
2k views

Using COPY in psql script does not write to file

I have a script with multiple queries I am triying to write to a csv file: copy ( select /* very long query */ ) to '/tmp/report.csv' with csv header; And I run the script like this psql -d ...
1
vote
1answer
363 views

Exporting/Importing data from SQL Server 2014 to PostgreSQL 9.5 with tab delimited files

Not sure if anyone has run into this problem before and I am going a little bit crazy. I am exporting a table from SQL Server 2014 using BCP to a tab delimited text file and then uploading the file ...
1
vote
1answer
2k views

How do I use the `COPY` command with JDBC

So I've been working with postgre databases and I noticed that it throws an error sometimes when I try to read a csv file and copy to a table remotely. It works perfectly when I use a buffered reader ...
2
votes
1answer
420 views

Parsing COPY's binary format to access a tsrange

How is tsrange stored in binary? For example create table CREATE TABLE public.test (t tsrange); INSERT INTO test VALUES ('[2010-01-01 14:30, 2010-01-01 15:30)'); INSERT INTO test VALUES ('[2011-01-...
-3
votes
1answer
2k views

Trigger after insert

How would look syntax of Trigger creation for Copying Column1 from table 1 in to new table 2 after instert value into any of columns of Table 1 ?
0
votes
1answer
203 views

get stuck trying to copy or backup database in microsoft SQL server [closed]

I have a website running on a windows hosting package with my provider. I bought a new windows hosting package, and now i want to copy my 'older' site into the new pack. SO I can acces the old db and ...
0
votes
2answers
264 views

update table with data from other table in remote oracle db

I have table X from remote Oracle DB A, and table Y in local Oracle DB B. The data in Y is a partial copy of the data in X (X has some columns that aren't needed in Y; the columns I need in Y have ...
2
votes
1answer
2k views

PostgreSQL PSQL client-side commands and new lines (\COPY)

The error message is the same with super user using COPY. The files are located on the same server as the postgres server. Saw many similar posting but not a single one answer my question. \copy ...
1
vote
0answers
441 views

Postgres performance issue during /copy

I run a weekly load from csv files on one of my Postgressql tables (27 GB) using /copy command. During this time, the response time of all other tables in the database increases ( from 4-8 ms to 300 ...
2
votes
1answer
811 views

Postgres COPY, is it possible to load multiple files into the same table?

Is it possible to execute several \copy commands in parallel against the same table? I know something similar exists with pg_restore, but that splits the work up amongst tables. I'm working with ...
0
votes
1answer
20 views

Copying Tables (partly replicating) databases remotely

I am having hard time figuring out a possible solution copying data from a tables to another. I have 2 databases (DB1 and DB2). DB1 and DB2 has the following tables (eg): Product Contacts Sales ...
0
votes
2answers
1k views

How to SELECT with two CSV files/… on PostgreSQL? [closed]

I have two CSV files which you can insert into the following PostgreSQL schema. However, I cannot \COPY the data into the tables. Pseudocode Let data_id=1 Show name and event_value from data.csv and ...
0
votes
1answer
147 views

What's causing my postgresql database to freeze? [duplicate]

This is my current setup on my home laptop: OSX El Capitan. Installed postgresql 9.6 via postgres.app. Symlinked the database files to an external HD (connected via USB). Inserting data via the ...
2
votes
0answers
523 views

How to transfer table from one database to another in postgresql

pg_dump -h host_ip -U postgres -d source_db -t aa_nqrgs.act_26022017 | psql -h destination_host_ip -U postgres -d destination_db I have tried this command to transfer a table from one server to ...
4
votes
1answer
560 views

Transfer microsecond timestamp into table using COPY

I need to transfer a microsecond timestamp into a table by using the COPY command. My approach using a normal INSERT, where X is a timestamp (since 1.1.1970) in microseconds, looked like this: ...
0
votes
2answers
284 views

SQL How to copy text from one table (from one column) to another table (to one column), preferably with IF the target column is empty

I have two tables in a database and I wish to copy text from one column of the table to another column in another table. Lets say I have two tables called 'articles' and 'info'. I have to copy ...
0
votes
1answer
129 views

To what extent do the “non-durability features” affect COPY's performance?

COPY is documented as not being WAL-logged if it's loaded on the same transactions.. In minimal level, WAL-logging of some bulk operations can be safely skipped, which can make those operations ...
-1
votes
1answer
169 views

How can I create a readable/writable clone of a log shipped standby/read only database?

I need to take adhoc copies of a development database (on SQL Server 2005) to another SQL Server and be able to read/write to that cloned database. As the SQL Servers are in different data centres, ...
2
votes
1answer
401 views

Wildcard for meta-command in postgresql

I am searching if there is a wildcard assigned to the \ meta-commandsSee description - meta-commands in Postgresql. for example.. postgresql=> \copy scheme.table FROM 'D:\path\to\%.csv' DELIMITER ...
2
votes
1answer
2k views

Why doesn't postgresql COPY command work with files in mapped drives

I have a problem copying CSV files from a network shared drive into postgreSQL, at present the fix is to copy the files to a local drive first, but it's another process in a chain which is becoming ...
0
votes
1answer
140 views

PostgreSQL exits the shell when importing large data

I'm having this totally weird scenario: We have an archiving server based on PostgreSQL inside a Scientific Linux virtual server. I want to migrate the data (20+ GB) to a physical Scientific Linux ...
2
votes
2answers
4k views

copy command in postgresql to append data

I am executing copy command from a function execute 'copy (select * from tableName) to ''/tmp/result.txt''' It works fine. But, tableName is dynamic and will be having more tables (iterating in a ...
2
votes
2answers
40 views

Coping MySQL DB between two servers: which server shoud initiate the operation?

I want to copy a database from serverA to serverB. The servers can communicate directly with each other. So I'm able to do something like: ServerA is sending the database to ServerB: dbadm1@serverA:~...
3
votes
1answer
263 views

How to approach copying a schema for testing?

I'm an Oracle newb. The systems in question are strictly for developers to test against. We fire them up and then blow them away afterwards. Problem is that this takes as long as 8 minutes per build ...
0
votes
0answers
325 views

How can I copy an entire schema from within a remote session?

Pursuant to this series of questions: How do I copy a schema for an instance of Oracle running in a Docker container? How can I copy an entire schema from within a remote session? SQL Developer, for ...
0
votes
1answer
351 views

How do I copy a schema for an instance of Oracle running in a Docker container?

Pursuant to this question: Is this package missing and if so, how do I fix? ...now I actually want to perform the copy of a schema using this package. ...except I can't figure out how to do that. I'...
1
vote
0answers
35 views

MySQL: INSERT SELECT to two databases (STORED FUNCTION)

I have to copy values of two twowith slight differences. One of the databases has to get the new corresponding id of the other. Hard to explain, so I'll do it with an example: These tables are ...
2
votes
3answers
6k views

INSERT and DELETE in single operation (moving from one table to other)

Stemming from this question, I am going to use that complex sort's results to decide which rows' data to move from one table to another. Though I have not yet tried it, I think there should be no ...