You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Export database as SQL produces invalid SQL for PostgreSQL #1031
Execute the following script against the temporary database:
CREATE SEQUENCE IF NOT EXISTS driver_id_seq START 1;
CREATE TABLE IF NOT EXISTS "driver" (
"id" INTEGER NOT NULL DEFAULT nextval('driver_id_seq'::regclass),
"first_name" TEXT NULL DEFAULT NULL,
"last_name" TEXT NULL DEFAULT NULL,
PRIMARY KEY ("id")
);
CREATE INDEX IF NOT EXISTS "driver_database_name_name_idx" ON driver ("first_name", "last_name");
From HeidiSQL, Right click on the database and choose "Export database as SQL".
Ensure that only the driver table is selected in the options;
Ensure that the Table(s) Create option is checked.
Set the Output option as desired.
Press the Export button.
Current behavior
HeidiSQL generates the following SQL:
CREATE TABLE IF NOT EXISTS "driver" (
"id" INTEGER NOT NULL DEFAULT 'nextval(''driver_id_seq''::regclass)',
"first_name" TEXT NULL DEFAULT NULL,
"last_name" TEXT NULL DEFAULT NULL,
INDEX "driver_database_name_name_idx" ("first_name", "last_name"),
PRIMARY KEY ("id")
);
This syntax cannot be executed in PostgreSQL using HeidiSQL.
Expected behavior
The generated SQL must be as show in step 1.
Varitions in syntax.
The "IF NOT EXISTS" is optional.
The CREATE SEQUENCE IF NOT EXISTS driver_id_seq START 1; can be replaced with SERIAL. EG:
CREATE TABLE IF NOT EXISTS "driver" (
"id" SERIAL,
"first_name" TEXT NULL DEFAULT NULL,
"last_name" TEXT NULL DEFAULT NULL,
PRIMARY KEY ("id")
);
CREATE INDEX IF NOT EXISTS "driver_database_name_name_idx" ON driver ("first_name", "last_name");
Possible solution
Environment
This has been tried in several version 9 databases.
The whole SQL export is very MySQL focused, due to historical reasons. Also, the high amount of differences in the SQL syntax makes it extremely different to generate valid SQL exports.
Activity
mmm8955405 commentedon Jul 22, 2022
I also encountered this problem
epremuz commentedon Mar 14, 2024
I also encountered this issue when attempting to migrate from MariaDB to PostgreSQL.
ansgarbecker commentedon Oct 14, 2025
The whole SQL export is very MySQL focused, due to historical reasons. Also, the high amount of differences in the SQL syntax makes it extremely different to generate valid SQL exports.