Questions tagged [copy]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
3answers
56 views

Copy table from one server to another including keys and indexes

I have been working on a small project for about two weeks. We want to consolidate a few tables from several remote server databases in order to run queries and reports on separate from the live ...
0
votes
0answers
36 views

How to copy/export part of my SQL database

So I have this huge live SQL database. I want to do some testing so I thought to export it, however, it is around 200 GB which is impossible to export. I thought maybe I export the schema of it and ...
1
vote
2answers
20 views

Postgres \copy command into single column without delimiter

I am trying to import big fixed length files into Postgres and I am using the copy command and a staging table following this guide. The problem is that this files has a lot of different characters ...
0
votes
1answer
41 views

The simplest way to copy sql tables from one database to another?

So I have been logged into two different database. I want to copy one table from the first database to the other one with its content. I want to overwrite the content of the destination one (Because I ...
0
votes
0answers
15 views

regularly calculating data and then loading to production database

I have a Postgres database running a small website. Most of the tables in the database are calculated values derived from various input data. This input data is updated approximately monthly. The ...
3
votes
1answer
105 views

Fastest way to extract full table in Postgres

I'm trying to dump a table with 50M records to a file, and my goal is to reduce the time in which this action is performed. I usually use the COPY metrics TO 'metrics.csv' DELIMITER ',' CSV; This ...
1
vote
2answers
155 views

Log Shipping Copy Job Fails once in a while

I have configured log shipping at multiple database server with monitored server(separate server) and all of them are running fine without any issues. One particular server has 7 database and the ...
2
votes
1answer
103 views

Best way to copy data to other location without blocking source

I have a production database with some data I need to copy to other location, either another database on the same server or another server. The DB size is huge and I don't need all the data on the DB,...
0
votes
1answer
105 views

SELECT vs COPY (SELECT) TO STDOUT

I need to read more rows than fit in memory, resonably fast. I see two options: SELECT ... where my bindings use a cursor to stream the rows; COPY (SELECT ...) TO STDOUT (FORMAT binary) where my ...
0
votes
0answers
16 views

PostgreSQL Copy From Ruby Variable

I have a set of records I need to INSERT into PostgreSQL. I thought I'd use the COPY command instead. Is there a way I can use this with a current array I have in ruby? It's a 2D array with each ...
0
votes
2answers
42 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
182 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?
-2
votes
1answer
1k 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
283 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
257 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
111 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
688 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
314 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
276 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
30 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
432 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
59 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
89 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
230 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
255 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
41 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
808 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
435 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
1k 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 ...
2
votes
1answer
2k 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
497 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
5k 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 ...
2
votes
1answer
643 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
4k 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
1k 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-...
-2
votes
1answer
3k 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
362 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
300 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
3k 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
636 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
1k 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
2k 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
199 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
676 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 ...
3
votes
1answer
810 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
1k 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
158 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
206 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
607 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 ...