pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Find missing data in a column
8+ messages / 5 participants
[nested] [flat]

* Find missing data in a column
@ 2021-12-29 17:43  john polo <jpolo@mail.usf.edu>
  0 siblings, 4 replies; 8+ messages in thread

From: john polo @ 2021-12-29 17:43 UTC (permalink / raw)
  To: pgsql-general

Hi,

I have a database in PostgreSQL 12 on Windows. It has > 8,000,000 rows. 
I want to copy this database to PostgreSQL 10 on Slackware Linux. I used 
this command to get the data out of the Windows database:

"C:\Program Files\PostgreSQL\12\bin\pg_dump.exe" 
--file="C:\Users\Nightrunner\DOCUMENTS\programming\pg_out\ebird_sptl_all.dump" 
--host="localhost" --port="5432" --username="postgres" --password 
--verbose --format=c --no-owner --no-privileges --dbname="ebird_work" 
--table="p_loc.ebd_sptl"

On Slackware, I first:

su postgres

Then try:

psql ebirds

SET SEARCH_PATH TO p_loc;

COPY p_loc.ebird_sptl FROM 
'/nt-d/projects_and_data/ebd_OR/ebird_sptl_all.dump';

That fails with

missing data for column "COMMON_NAME"

I understand this means there is a problem with one or more rows in the 
column referenced. This is a column of text. How do I find the error(s) 
in question?

Cheers,

John

-- 
Enlightenment is ego's ultimate disappointment.
-Chogyam Trungpa






^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Find missing data in a column
@ 2021-12-29 17:54  David G. Johnston <david.g.johnston@gmail.com>
  parent: john polo <jpolo@mail.usf.edu>
  3 siblings, 0 replies; 8+ messages in thread

From: David G. Johnston @ 2021-12-29 17:54 UTC (permalink / raw)
  To: john polo <jpolo@mail.usf.edu>; +Cc: pgsql-general

On Wednesday, December 29, 2021, john polo <jpolo@mail.usf.edu> wrote:

>
> I understand this means there is a problem with one or more rows in the
> column referenced. This is a column of text. How do I find the error(s) in
> question?
>

It doesn’t actually mean anything…you cannot use the copy command to import
the contents of a dump file.  Especially not one dumped using the custom
format.

David J.

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Find missing data in a column
@ 2021-12-29 17:56  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: john polo <jpolo@mail.usf.edu>
  3 siblings, 0 replies; 8+ messages in thread

From: Adrian Klaver @ 2021-12-29 17:56 UTC (permalink / raw)
  To: john polo <jpolo@mail.usf.edu>; pgsql-general

On 12/29/21 09:43, john polo wrote:
> Hi,
> 
> I have a database in PostgreSQL 12 on Windows. It has > 8,000,000 rows. 
> I want to copy this database to PostgreSQL 10 on Slackware Linux. I used 
> this command to get the data out of the Windows database:
> 
> "C:\Program Files\PostgreSQL\12\bin\pg_dump.exe" 
> --file="C:\Users\Nightrunner\DOCUMENTS\programming\pg_out\ebird_sptl_all.dump" 
> --host="localhost" --port="5432" --username="postgres" --password 
> --verbose --format=c --no-owner --no-privileges --dbname="ebird_work" 
> --table="p_loc.ebd_sptl"
> 
> On Slackware, I first:
> 
> su postgres
> 
> Then try:
> 
> psql ebirds
> 
> SET SEARCH_PATH TO p_loc;
> 
> COPY p_loc.ebird_sptl FROM 
> '/nt-d/projects_and_data/ebd_OR/ebird_sptl_all.dump';
> 
> That fails with
> 
> missing data for column "COMMON_NAME"
> 
> I understand this means there is a problem with one or more rows in the 
> column referenced. This is a column of text. How do I find the error(s) 
> in question?

How did you think this would work at all?

--format=c is compressed custom binary format

COPY p_loc.ebird_sptl FROM 
'/nt-d/projects_and_data/ebd_OR/ebird_sptl_all.dump';

Is looking for separated value text format file.

Look at pg_restore:

https://www.postgresql.org/docs/current/app-pgrestore.html

> 
> Cheers,
> 
> John
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Find missing data in a column
@ 2021-12-29 18:07  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: john polo <jpolo@mail.usf.edu>
  3 siblings, 1 reply; 8+ messages in thread

From: Adrian Klaver @ 2021-12-29 18:07 UTC (permalink / raw)
  To: john polo <jpolo@mail.usf.edu>; pgsql-general

On 12/29/21 09:43, john polo wrote:
> Hi,
> 
> I have a database in PostgreSQL 12 on Windows. It has > 8,000,000 rows. 
> I want to copy this database to PostgreSQL 10 on Slackware Linux. I used 
> this command to get the data out of the Windows database:
> 
> "C:\Program Files\PostgreSQL\12\bin\pg_dump.exe" 
> --file="C:\Users\Nightrunner\DOCUMENTS\programming\pg_out\ebird_sptl_all.dump" 
> --host="localhost" --port="5432" --username="postgres" --password 
> --verbose --format=c --no-owner --no-privileges --dbname="ebird_work" 
> --table="p_loc.ebd_sptl"
> 
> On Slackware, I first:
> 
> su postgres
> 
> Then try:
> 
> psql ebirds
> 
> SET SEARCH_PATH TO p_loc;
> 
> COPY p_loc.ebird_sptl FROM 
> '/nt-d/projects_and_data/ebd_OR/ebird_sptl_all.dump';
> 
> That fails with
> 
> missing data for column "COMMON_NAME"
> 
> I understand this means there is a problem with one or more rows in the 
> column referenced. This is a column of text. How do I find the error(s) 
> in question?


If you want to use psql then:

pg_dump.exe" 
--file="C:\Users\Nightrunner\DOCUMENTS\programming\pg_out\ebird_sptl_all.txt" 
--host="localhost" --port="5432" --username="postgres" --password 
--no-owner --no-privileges --dbname="ebird_work" 
--table="p_loc.ebd_sptl" --data-only

psql ebirds


\i C:\Users\Nightrunner\DOCUMENTS\programming\pg_out\ebird_sptl_all.txt



> 
> Cheers,
> 
> John
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Find missing data in a column
@ 2021-12-29 18:10  Rob Sargent <robjsargent@gmail.com>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Rob Sargent @ 2021-12-29 18:10 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: john polo <jpolo@mail.usf.edu>; pgsql-general



> On Dec 29, 2021, at 10:07 AM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
> 
> On 12/29/21 09:43, john polo wrote:
>> Hi,
>> I have a database in PostgreSQL 12 on Windows. It has > 8,000,000 rows. I want to copy this database to PostgreSQL 10 on Slackware Linux. I used this command to get the data out of the Windows database:
>> "C:\Program Files\PostgreSQL\12\bin\pg_dump.exe" --file="C:\Users\Nightrunner\DOCUMENTS\programming\pg_out\ebird_sptl_all.dump" --host="localhost" --port="5432" --username="postgres" --password --verbose --format=c --no-owner --no-privileges --dbname="ebird_work" --table="p_loc.ebd_sptl"
>> On Slackware, I first:
>> su postgres
>> Then try:
>> psql ebirds
>> SET SEARCH_PATH TO p_loc;
>> COPY p_loc.ebird_sptl FROM '/nt-d/projects_and_data/ebd_OR/ebird_sptl_all.dump';
>> That fails with
>> missing data for column "COMMON_NAME"
>> I understand this means there is a problem with one or more rows in the column referenced. This is a column of text. How do I find the error(s) in question?
> 
> 
> If you want to use psql then:
> 
> pg_dump.exe" --file="C:\Users\Nightrunner\DOCUMENTS\programming\pg_out\ebird_sptl_all.txt" --host="localhost" --port="5432" --username="postgres" --password --no-owner --no-privileges --dbname="ebird_work" --table="p_loc.ebd_sptl" --data-only
> 
> psql ebirds
> 
> 
> \i C:\Users\Nightrunner\DOCUMENTS\programming\pg_out\ebird_sptl_all.txt
> 

Doesn’t that presume OP can connect to linux db from Windows machine?  Seems the best plan would be copy to; file-tranfer; copy from
> 
> 
>> Cheers,
>> John
> 
> 
> -- 
> Adrian Klaver
> adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Find missing data in a column
@ 2021-12-29 18:16  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Rob Sargent <robjsargent@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Adrian Klaver @ 2021-12-29 18:16 UTC (permalink / raw)
  To: Rob Sargent <robjsargent@gmail.com>; +Cc: john polo <jpolo@mail.usf.edu>; pgsql-general

On 12/29/21 10:10, Rob Sargent wrote:
> 
> 

>> If you want to use psql then:
>>
>> pg_dump.exe" 
>> --file="C:\Users\Nightrunner\DOCUMENTS\programming\pg_out\ebird_sptl_all.txt" 
>> --host="localhost" --port="5432" --username="postgres" --password 
>> --no-owner --no-privileges --dbname="ebird_work" 
>> --table="p_loc.ebd_sptl" --data-only
>>
>> psql ebirds
>>
>>
>> \i C:\Users\Nightrunner\DOCUMENTS\programming\pg_out\ebird_sptl_all.txt
>>
> 
> Doesn’t that presume OP can connect to linux db from Windows machine? 
>   Seems the best plan would be copy to; file-tranfer; copy from

Yeah that should been the file location from the OP's COPY command:

'/nt-d/projects_and_data/ebd_OR/ebird_sptl_all.txt'

>>
>>
>>> Cheers,
>>> John
>>
>>
>> --
>> Adrian Klaver
>> adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Find missing data in a column
@ 2021-12-29 18:36  Alan Hodgson <ahodgson@lists.simkin.ca>
  parent: john polo <jpolo@mail.usf.edu>
  3 siblings, 0 replies; 8+ messages in thread

From: Alan Hodgson @ 2021-12-29 18:36 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

On Wed, 2021-12-29 at 12:43 -0500, john polo wrote:
> I have a database in PostgreSQL 12 on Windows. It has > 8,000,000
> rows. 
> I want to copy this database to PostgreSQL 10 on Slackware Linux. I
> used 
> this command to get the data out of the Windows database:
> 
> "C:\Program Files\PostgreSQL\12\bin\pg_dump.exe" 
> --
> file="C:\Users\Nightrunner\DOCUMENTS\programming\pg_out\ebird_sptl_
> all.dump" 
> --host="localhost" --port="5432" --username="postgres" --password 
> --verbose --format=c --no-owner --no-privileges --
> dbname="ebird_work" 
> --table="p_loc.ebd_sptl"
> 
> On Slackware, I first:
> 
> su postgres
> 
> Then try:
> 
> psql ebirds
> 
> SET SEARCH_PATH TO p_loc;
> 
> COPY p_loc.ebird_sptl FROM 
> '/nt-d/projects_and_data/ebd_OR/ebird_sptl_all.dump';
> 
> That fails with
> 
> missing data for column "COMMON_NAME"
> 
> I understand this means there is a problem with one or more rows in
> the 
> column referenced. This is a column of text. How do I find the
> error(s) 
> in question?

You're going to want to look into the pg_restore command to restore a
custom format dump file.

If you wanted something to read with COPY FROM you would first dump
it with COPY TO.

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Find missing data in a column
@ 2021-12-30 02:09  john polo <jpolo@mail.usf.edu>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 0 replies; 8+ messages in thread

From: john polo @ 2021-12-30 02:09 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-general

On 12/29/2021 1:16 PM, Adrian Klaver wrote:
> On 12/29/21 10:10, Rob Sargent wrote:
>>
>>
>
>>> If you want to use psql then:
>>>
>>> pg_dump.exe" 
>>> --file="C:\Users\Nightrunner\DOCUMENTS\programming\pg_out\ebird_sptl_all.txt" 
>>> --host="localhost" --port="5432" --username="postgres" --password 
>>> --no-owner --no-privileges --dbname="ebird_work" 
>>> --table="p_loc.ebd_sptl" --data-only
>>>
>>> psql ebirds
>>>
>>>
>>> \i C:\Users\Nightrunner\DOCUMENTS\programming\pg_out\ebird_sptl_all.txt
>>>
>>
>> Doesn’t that presume OP can connect to linux db from Windows machine? 
>>   Seems the best plan would be copy to; file-tranfer; copy from
>
> Yeah that should been the file location from the OP's COPY command:
>
> '/nt-d/projects_and_data/ebd_OR/ebird_sptl_all.txt'
>
Thanks, everyone, for the replies.

Thanks, Adrian, for the helpful commands you provided. They worked up to 
a point that gave me a different error as the data were loading. I will 
spend some time trying to work that new error out.

Cheers,

John







^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2021-12-30 02:09 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-12-29 17:43 Find missing data in a column john polo <jpolo@mail.usf.edu>
2021-12-29 17:54 ` David G. Johnston <david.g.johnston@gmail.com>
2021-12-29 17:56 ` Adrian Klaver <adrian.klaver@aklaver.com>
2021-12-29 18:07 ` Adrian Klaver <adrian.klaver@aklaver.com>
2021-12-29 18:10   ` Rob Sargent <robjsargent@gmail.com>
2021-12-29 18:16     ` Adrian Klaver <adrian.klaver@aklaver.com>
2021-12-30 02:09       ` john polo <jpolo@mail.usf.edu>
2021-12-29 18:36 ` Alan Hodgson <ahodgson@lists.simkin.ca>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox