I'm restoring a .sql Postgres dump on a database I created with
CREATE DATABASE my_database;
Later When I restore the database with
psql my_database < dump.sql
However, I encountered several errors which prevents me from restoring the data:
ERROR: schema "pglogical" already exists
ALTER SCHEMA
CREATE EXTENSION
COMMENT
ERROR: could not open extension control file "/usr/share/postgresql/11/extension/pglogical.control": No such file or directory
ERROR: extension "pglogical" does not exist
ERROR: could not open extension control file "/usr/share/postgresql/11/extension/postgis.control": No such file or directory
ERROR: extension "postgis" does not exist
ERROR: function "order_sorting_weight" already exists with same argument types
ERROR: type "public.geometry[]" does not exist
LINE 7: viewer_locations public.geometry(Point,4326)[]
Following by repeatedly reporting:
ERROR: relation "auth_permission_id_seq" already exists
ALTER TABLE
ALTER SEQUENCE
ERROR: relation "auth_user" already exists
ALTER TABLE
ERROR: relation "auth_user_groups" already exists
ALTER TABLE
ERROR: relation "auth_user_groups_id_seq" already exists
for each column of the db I guess.
How could I solve this issue?
OK, I solved the problem JUST by changing the version of posters I've been using, as I installed the latest version of Postgres (11.1), I couldn't restore the .sql dump files to it, and the dump file was getting dumped from a database server with version 9.5. so I just uninstalled the whole Postgresql and installed the 9.5 version of it. I setup pglogical extension with help of plogical-docs and now everything works just as I wanted.
Related
I was given a database file , i don't know the userid who dumped it or it's privileges .
I use postgresql 9.6.7-1 with pg_admin4(v3.0) , OS: windows 10
First, i created a database in pgadmin with same name as the given file.
I used the restore option to restore the file but after some seconds
i got type of messages like :
pg_restore: executing SEQUENCE SET xxxx
pg_restore: [archiver (db)] Error from TOC entry 4309; 0 0 SEQUENCE SET xxxx postgres
pg_restore: [archiver (db)] could not execute query: ERROR: relation "public.xxxx" does not exist
LINE 1: SELECT pg_catalog.setval('public.xxxx', 1, false);
^
Command was: SELECT pg_catalog.setval('public.xxxx', 1, false);
and below all, the warning :
"WARNING: errors ignored on restore: 62"
comparing with other's answers i dont even get a single bit of data restored.
I have tried also with
pg_restore
command but i get the same result .
It looks like the dump you were given is not a complete backup. It only has the data, not the object definitions. That is, it was created by pg_dump using -a, --data-only, or --section=data.
Unless you already know what the object definitions are from some other source (e.g., an existing database server with the same schema definitions, or a dump file generated with pg_dump -s), you will have a hard time loading this data.
{solved}
please check the version of the Postgresql pgAdmin4 and the version of ".Sql" file you want to import into your database ,and instead of restoring at public you should directly restore at the database itself.
2:- drop the database and again re-create the fresh database(name='xyz') & at the same database ('xyz'** ->RightClick->Restore->Filename->'select(formate ".sql")->Restore**) than->refresh the database.
and by doing that it'll create i new Schema just above public Schema..
I'm trying to move a database in Postgres 8.2 to a new tablespace, but when running ALTER DATABASE data_base_name SET TABLESPACE TO tbspc_name
the following error appears ERROR: unrecognized configuration parameter "tablespace".
It seems that in Postgres 8.2 you have two options:
move tables one by one, see ALTER TABLE ...;
backup the database, create a new one with a tablespace defined, and restore the backup in the new database, see CRETE DATABASE ....
I am trying to import the spatial file in to my database
Firstly i have created a database using postgis template as below
createdb -T template_postgis database_name;
I have postgis installed already on my machine
POSTGIS="2.1.1 r12113" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.9.0, released 2011/12/29" LIBXML="2.7.8" LIBJSON="UNKNOWN" TOPOLOGY RASTER
Postgres version : psql (9.3.2, server 9.1.11)
Secondly i have converted the spatial file in to sql file as below
shp2pgsql -s 3425 Aspire.shp test_for_shape_data database_name > shapefile_data.sql
And now i am trying to import this sql file(shapefile_data.sql) in to my database(database_name) like below
psql -d database_name username -f shapefile_data.sql
But i am getting the following error
user#user:~/user/spice$ psql -d psql -d database_name username -f shapefile_data.sql
SET
SET
BEGIN
psql:shapefile_data.sql:30: NOTICE: CREATE TABLE will create implicit sequence "test_for_shape_data_gid_seq" for serial column "test_for_shape_data.gid"
CREATE TABLE
psql:shapefile_data.sql:31: NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "test_for_shape_data_pkey" for table "test_for_shape_data"
ALTER TABLE
psql:shapefile_data.sql:32: ERROR: function addgeometrycolumn(unknown, unknown, unknown, unknown, unknown, integer) is not unique
LINE 1: SELECT AddGeometryColumn('','test_for_shape_data','geom','42...
^
HINT: Could not choose a best candidate function. You might need to add explicit type casts.
psql:shapefile_data.sql:33: ERROR: current transaction is aborted, commands ignored until end of transaction block
psql:shapefile_data.sql:34: ERROR: current transaction is aborted, commands ignored until end of transaction block
...........
.......
Why it is telling me that i don't have AddGeometryColumn function even though i have created the database with postgis template ?
So how to avoid this ?
Also when i try to manually enable the postgis functions its telling that already exists
database_name=# CREATE EXTENSION postgis;
ERROR: type "spheroid" already exists
database_name=# CREATE EXTENSION postgis_topology;
ERROR: required extension "postgis" is not installed
So how to clear this error and insert the shapefile sql file in to database ?
It sounds like you've got an old PostGIS install that was created from an SQL script, pre-extension support. It probably only has some of the functionality and features you expect. This sort of behaviour can occur when you've got a PostGIS 1.5 schema and a PostGIS 2.0 install, etc.
Try creating your DB from template0 instead, and running CREATE EXTENSION postgis; then doing a restore. I suspect your template_postgis contains an old version of the extension schema.
See the PostGIS upgrade guide.
I have PostGIS 2.0.4 installed with PostgreSQL 9.2.4, trying to enable spatial database extension with the following command:
CREATE EXTENSION postgis;
but encountered an error -
ERROR: must be owner of type spheroid
What is this spheroid type? How could I enable it?
Update:
Well, I still couldn't find a solution so I had to remove everything and reinstall again. Now I am getting a new error saying:
ERROR: could not load library "/usr/pgsql-9.2/lib/rtpostgis-2.0.so": libclntsh.so.11.1 cannot open shared object file: No such file or directory.
I have no luck google out an answer to this. It seems libclntsh.so.11.1 is a Oracle library? Why it has something to do with PostgreSQL?
Try logging in as a db superuser. On Linux the following should work on most distros:
sudo postgres psql [dbname]
Then ownership and permissions can be effectively ignored. In general I would recommend doing this for most extension installations as this usually requires superuser privileges anyway.
I know this is an ancient question, but I want an answer here for the next time I run into it!
Drop the tables spatial_ref_sys and geometry_columns. They shouldn't be tables in your schema. In my case, they got created as an artefact of using DotNet to create Entity Framework models from a SQL Server database, then using EF to recreate the DB in Postgres.
So:
sudo postgresql psql [dbname] -c "drop table spatial_ref_sys; drop table geometry_columns; create extension postgis;"
I am trying to import a sql dump to postgresql db as -
sudo su postgres -c psql dbname < mydb_dump.sql
This gives errors as -
SET
SET
SET
SET
SET
SET
ERROR: function "array_accum" already exists with same argument types
ALTER AGGREGATE
ERROR: function "c" already exists with same argument types
ALTER AGGREGATE
ERROR: duplicate key value violates unique constraint "pg_ts_config_cfgname_index"
ERROR: duplicate key value violates unique constraint "pg_ts_config_map_index"
and so on this. What might be wrong with that? Tried googling for it, but couldn't find any pointers over it.
Postgresql version is 8.4.1
Thanks !!
you should to remove shared functions and objects from database, before you do dump or before you load dump. You have these functions and objects registered in template1, and when you create new database, then these objects are there - and you can see errors when dump try to create it again.
This issue is well solved in PostgreSQL 9.1. For older versions try to use option --clean for pg_dump
Pavel