1

I am trying to "dump" a table to a file, copy that file to a different host and restore the table on a database.

My (first) problem is that I cannot dump the table data.

I use this command:

pg_dump.exe --host=localhost --dbname=mydb --username=postgres -f .\sensordata2.backup -v -t sensordata2

But even though the "sensordata2" table has millions of rows, the "dump" file produced by said command is only 2 kb and has no insert statements corresponding with existing rows in "sensordata2". I don't understand why.

I also tried using the pgAdmin GUI to do this, but the result are similar. There are no insert statements in the "dump" file for the rows in "sensordata2".

This is the "dump" file I get (as you can see, nothing about the actual rows in "sensordata2"):

--
-- PostgreSQL database dump
--

-- Dumped from database version 14.1
-- Dumped by pg_dump version 14.1

-- Started on 2022-02-10 08:52:24

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- TOC entry 3893 (class 1262 OID 18013)
-- Name: mydb; Type: DATABASE; Schema: -; Owner: postgres
--

CREATE DATABASE mydb WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE = 'English_United Kingdom.1252';


ALTER DATABASE mydb OWNER TO postgres;

\connect mydb

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- TOC entry 3887 (class 0 OID 18795)
-- Dependencies: 282
-- Data for Name: sensordata2; Type: TABLE DATA; Schema: public; Owner: postgres
--



-- Completed on 2022-02-10 08:52:24

--
-- PostgreSQL database dump complete
--
2
  • I don't believe that that is the command line you used. That one would not include a CREATE DATABASE command.
    – jjanes
    Commented Feb 10, 2022 at 21:39
  • The command I show was one I ran in the terminal. The output I show is what came from doing the "backup" with pgAdmin.
    – birgersp
    Commented Feb 11, 2022 at 5:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.