1

I have made a database backup with heidisql. When I try to restore the backup, I get A syntax error.

The query that heidiSQL generated for me:

CREATE TABLE IF NOT EXISTS "age_categories" (
    "id" INTEGER NOT NULL DEFAULT nextval('age_categories_id_seq'::regclass) COMMENT E'',
    "created_at" TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL COMMENT E'',
    "updated_at" TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL COMMENT E'',
    "min_age" INTEGER NOT NULL DEFAULT 0 COMMENT E'',
    "max_age" INTEGER NOT NULL DEFAULT 0 COMMENT E'',
    PRIMARY KEY ("id")
);

The error I get when I run the query:

ERROR:  syntax error at or near "COMMENT"
LINE 3: ...EFAULT 
nextval('age_categories_id_seq'::regclass) COMMENT 
E'...                              ^

I dont understand what exactly is going wrong here, any ideas?

1 Answers1

2

Whatever heidisql is, it generates SQL that is not legal in PostgreSQL.

If that's supposed to work with PostgreSQL, you should file a bug report.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • Heidisql is https://www.heidisql.com/. If this query is not legel PostgreSQL, could you tell me which part of it makes it illegal? – user2315111 Jul 16 '19 at 12:22
  • Sorry, I guess that wasn't very clear. I was refering to the query in my question :) – user2315111 Jul 16 '19 at 13:16
  • I think `E''` is suppose to be the comment for each column? – user2315111 Jul 18 '19 at 08:45
  • 1
    Yes, I can see that. But that is not valid SQL. There is no `COMMENT` clause in the [syntax of `CREATE TABLE`](https://www.postgresql.org/docs/current/sql-createtable.html). – Laurenz Albe Jul 18 '19 at 09:04
  • Ah you are correct, once I removed the `COMMENT E''` parts, the query runs almost. (`age_categories_id_seq` does not seem to exist). I will send a bug report to heidisql. Thank you for your help! – user2315111 Jul 18 '19 at 10:51