0

I created a table using pgadmin4 on windows. Then I copied the create table query from pgadmin4 SQL window and pasted in psql command line on ubuntu 18.04.

It's raising following error:

ERROR:  relation "weather_measurements_meas_id_seq" does not exist

This is create table query that I copy from pgadmin4:

CREATE TABLE public.weather_measurements
(
    meas_id bigint NOT NULL DEFAULT nextval('weather_measurements_meas_id_seq'::regclass),
    meas_dev_id integer NOT NULL,
    "dateTime" timestamp without time zone,
    w_speed real,
    w_gust real,
    w_direction real,
    w_unit character varying COLLATE pg_catalog."default",
    humidity real,
    pressure integer,
    light integer,
    rain integer,
    "2nd_temp" real,
    lws real,
    lws_cnt real,
    solar integer,
    temperature real,
    CONSTRAINT weather_measurements_pkey PRIMARY KEY (meas_id),
    CONSTRAINT meas_dev_id FOREIGN KEY (meas_dev_id)
        REFERENCES public.measuring_devices (meas_dev_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)
WITH (
    OIDS = FALSE
)
TABLESPACE pg_default;

ALTER TABLE public.weather_measurements
    OWNER to postgres;

How to correct it.

XCeptable
  • 1,247
  • 6
  • 25
  • 49
  • 2
    Check whether you have a sequence called "'weather_measurements_meas_id_seq". If you don't, create it. – 404 Oct 25 '18 at 10:11
  • 2
    Unrelated but all your fields use `snake_case` except `"dateTime"`. Don't mix and match styles, choose one and use it for all. – 404 Oct 25 '18 at 10:13
  • 1
    @eurotrash: thank you, It's solved and thank you for advice about style. I change it too. – XCeptable Oct 25 '18 at 10:21
  • If you are using PG 10 or later you can use `meas_id BIGINT GENERATED BY DEFAULT AS IDENTITY` which will create the sequence for you. If you need to speicfy the properties of the sequence you can use `meas_id BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 10 INCREMENT BY 10)` – quasar Oct 25 '18 at 11:06

0 Answers0