Skip to main content
February 21, 2025
Solved

Error importing schema on DBMS ER

When running the recommended import script on my Postgresql V17 database (Ubuntu 24)

 

Any help appreciated

Error is:

ERROR:  syntax error at or near "="LINE 1: SELECT COUNT(*) AS total FROM (SET enable_nestloop=0;SELECT …In statement:SELECT COUNT(*) AS total FROM (SET enable_nestloop=0;SELECT 'postgresql' AS dbms,t.table_catalog,t.table_schema,t.table_name,c.column_name,c.ordinal_position,c.data_type,c.character_maximum_length,n.constraint_type,k2.table_schema,k2.table_name,k2.column_name FROM information_schema.tables t NATURAL LEFT JOIN information_schema.columns c LEFT JOIN(information_schema.key_column_usage k NATURAL JOIN information_schema.table_constraints n NATURAL LEFT JOIN information_schema.referential_constraints r)ON c.table_catalog=k.table_catalog AND c.table_schema=k.table_schema AND c.table_name=k.table_name AND c.column_name=k.column_name LEFT JOIN information_schema.key_column_usage k2 ON k.position_in_unique_constraint=k2.ordinal_position AND r.unique_constraint_catalog=k2.constraint_catalog AND r.unique_constraint_schema=k2.constraint_schema AND r.unique_constraint_name=k2.constraint_name WHERE t.TABLE_TYPE='BASE TABLE' AND t.table_schema NOT IN('information_schema','pg_catalog')) AS sub
Humas1985
Humas1985Answer
Lucid Legend Level 10
February 23, 2025

​@kerrya - Kindly separate the SET command from your query.

First, run the command "SET enable_nestloop = OFF;" as a standalone statement.

Then, execute your SELECT query in a separate step and give a try.

----------------------------------------------------------------------------------

In addition, you can also try using different syntax to set the parameter. Instead of the original command, use either "SET enable_nestloop TO OFF;" or "SET enable_nestloop = 'OFF';" as some PostgreSQL versions support "TO" instead of "=" for this purpose. If issues persist, try removing the semicolon and executing "SET enable_nestloop TO OFF".

Keep us posted on the outcome!! 

Regards

Huma || Lucid Legend

Comments

Humas1985
Lucid Legend Level 10
Lucid Legend Level 10
February 22, 2025

Hi ​@kerrya 

Seems it is due to an incorrect use of SET enable_nestloop=0; within a SELECT statement

Try running SET enable_nestloop = OFF; separately before executing the query

Modify your script to separate the SET command from the SELECT statement, then give a try and keep us posted.

Best Regards

 

Translate
Huma || Lucid Legend
kerryaAuthor
February 22, 2025

 

Seems it is due to an incorrect use of SET enable_nestloop=0; within a SELECT statement

Try running SET enable_nestloop = OFF; separately before executing the query

Modify your script to separate the SET command from the SELECT statement, then give a try and keep us posted.

 

 

I tried to run “SET enable_nestloop = OFF;” as a separate instruction on it’s own and got the following error:
 

ERROR:  syntax error at or near "="LINE 1: ...ELECT COUNT(*) AS total FROM (SET enable_nestloop = OFF) AS …I’m using the phpPgAdmin interface using teh SQL tab to run these instructions.Kerry
Translate
Humas1985
Lucid Legend Level 10
Humas1985Lucid Legend Level 10Answer
Lucid Legend Level 10
February 23, 2025

​@kerrya - Kindly separate the SET command from your query.

First, run the command "SET enable_nestloop = OFF;" as a standalone statement.

Then, execute your SELECT query in a separate step and give a try.

----------------------------------------------------------------------------------

In addition, you can also try using different syntax to set the parameter. Instead of the original command, use either "SET enable_nestloop TO OFF;" or "SET enable_nestloop = 'OFF';" as some PostgreSQL versions support "TO" instead of "=" for this purpose. If issues persist, try removing the semicolon and executing "SET enable_nestloop TO OFF".

Keep us posted on the outcome!! 

Regards

Translate
Huma || Lucid Legend