0
CREATE TABLE IF NOT EXISTS "access_log" (
    "id" BIGINT NOT NULL DEFAULT 'nextval(''access_log_id_seq''::regclass)',
    "user_id" BIGINT NOT NULL,
    "platform" SMALLINT NOT NULL,
    "created_at" TIMESTAMP NULL DEFAULT NULL,
    "updated_at" TIMESTAMP NULL DEFAULT NULL,
    "device_id" VARCHAR(255) NULL DEFAULT NULL,
    "location" VARCHAR(255) NULL DEFAULT NULL,
    "ip" VARCHAR(255) NULL DEFAULT NULL,
    PRIMARY KEY ("id"),
    CONSTRAINT "access_log_user_id_foreign" FOREIGN KEY ("user_id") REFERENCES "public"."users" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
);

enter image description here I am trying to restore my PostgreSQL using HeidiSQL. It is showing invalid input syntax for type bigint.

enter image description here

8
  • 1
    Looks like the sequence is at the end of it's range Commented Jan 5, 2023 at 6:50
  • By the way, you have the wrong type for your created and updated columns. Should be timestamp with time zone. Commented Jan 5, 2023 at 7:43
  • @BasilBourque: Why would a timestamp be the wrong datatype? Commented Jan 5, 2023 at 8:15
  • Too many quotes ' in your statement, nextval() is a function and not a piece of text. Commented Jan 5, 2023 at 8:17
  • Unrelated, but: an IP address should be stored in a column defined as inet . Btw: there is no magic optimization when using 255 as the length limit for a varchar compared to e.g. 260 or 274` Commented Jan 5, 2023 at 8:46

1 Answer 1

1

The call of the nextval() function must not be quoted.

So this:

default 'nextval(''access_log_id_seq''::regclass)'

needs to be:

default nextval('access_log_id_seq'::regclass)
Sign up to request clarification or add additional context in comments.

2 Comments

I used this default nextval('access_log_id_seq'::regclass) but still not working.
@KapilDevSingh: "sill not working" is not a valid Postgres error message. The CREATE TABLE will work just fine if the sequence (and the table users) are created.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.