0

I have an old backup sql file with ` in it. When I try to load it via psql dbname < db_backup.sql I get an error:

ERROR:  syntax error at or near "`"
DROP TABLE IF EXISTS `tablename`;

Is there a way to tell psql to treat ` like '?

Some Guy
  • 12,768
  • 22
  • 58
  • 86
  • 3
    Backticks are invalid in an SQL identifier in standard SQL and Postgres. If at all you would need to make it treat them as double quotes: `"` because that's what the SQL standard uses to quote identifiers. You need to replace the dreaded backticks with double quotes. But if that file is a MySQL backup, there will be a lot more in there that needs adjusting to Postgres. –  Nov 30 '21 at 07:06

1 Answers1

1

You should create the dump using mysqldump --compatible=ansi to avoid this and other migration incompatibilities. I suggest you make a separate MySQL database using your existing backup as it is, then do a dump with this option to make the compatible one.

coladict
  • 4,799
  • 1
  • 16
  • 27