Importing sql dump from postgresql 9.6 to postgresql 10 - postgresql

I have a website with a Postgis database. I access to it with phpPgAdmin with postgreSQL 9.6. I want to export my database to keep a local backup.
I exported it like that:
Then I want to import it in PgAdmin 4 v2.1, with PostgreSQL 10. In my SQL file I changed the owner name from observatoire-vienne to postgres. I created an empty spatial database.
I selected the query tool and ran the query with my sql file.
The error message is:
ERROR: ERREUR: la fonction public._st_dumppoints(public.geometry, integer[]) n'existe pas
Which means:
Error: the function public._st_dumppoints(public.geometry, integer[]) does not exist
I can’t find a similar problem in previous posts.
My question is: Is it due to Postgres versions? Does someone have the solution?

Related

How to DROP tables from specific database-schema in Postgresql?

I am new to Postgresql and so far I have not found a way to drop a table from specific database. To give some context:
We are doing a synchronization from Oracle to PostgreSQL of 5 tables. In postgres I have a database SoloCopy and the schema is the default public. In the Postgresql instance we have also 2 more databases SoloSynch and postgres (the default one).
What I want to do is to select SoloCopy database and:
DROP TABLE public.table1;
When I do the above DROP statement table1 is deleted only from the database that was selected when opening SQL Query. But I want to specify the database before that and to be irrelevant from where the SQL Query was open. How can I do that?
I found an answer on my own. Setup can be found here:
Psql in Task Scheduler does not run a file script
Basically I needed to use PSQL and with the connection string there I connect to a specific DB, which I can drop the tables from. The details for PGPASSWORD and the .bat file I ended up creating are in the link above. Had to start everything from CMD and switch to psql from there.

Error when restoring PostGIS database: "type geometry does not exist"

So a colleague of mine is leaving our company and he used pg_dump (indirectly, through pgAdmin III) to dump his local database. He put the .backup file on the company server, and I'm now using pg_restor (indirectly, through pgAdmin III) to restore his tables into the company database.
But I noticed that only the tables without a geometry were restored.
When looking closely at the logs, I noticed that the error was the following (sorry about the French locale):
pg_restore: [programme d'archivage (db)] could not execute query: ERREUR: le type « geometry » n'existe pas
LIGNE 3 : geom geometry(Point,5699),
^
La commande était : CREATE TABLE cbt_poste (
id integer NOT NULL,
geom geometry(Point,5699),
nom_du_pos character varying(32),
d...
Basically, it states that the type Geometry does not exist. But when I create a table with a Geometry column, in whatever schema of the database, it works successfully.
So my problem is essentially:
When I create a table with a Geometry column, everything works...
But when pg_restore creates a table with a Geometry column, everything happens as if the PostGIS extension never had existed.
Any experience of this kind of issue?
I may assume, there's no PostGIS extension installed at the database, where you're trying to restore the dump. That's why spatial data types (geometry, in particular) are not getting recognized. You may try to install PostGIS and retry pg_restore.
See if you have postgis installed writing this in psql:
SELECT PostGIS_full_version();
if not installed, you can install it following the instructions in postgis install instructions
If you have postgis installed, you need to make sure the extension is available in your database, if it is not, you can create it with:
CREATE EXTENSION postgis;

Oracle database 12g user does not exist

I have a Oracle Database 12C and, when i do the following query on SYS schema
select * from all_users;
i get listed USER_X.
However, when i try to alter USER_X's password, by doing the following
ALTER USER USER_X IDENTIFIED BY XPTO_123;
i get the error
SQL Error: ORA-01918: 01918. 00000 - "user '%s' does not exist"
Am i missing something?
Thanks
How was the 12C database installed? Does it uses the "Multitenant" architecture?
If so, alter the user's password may differ for CDB and PDB.
You can refer to this and this links for more infos.

Enable PostGIS extension error

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;"

Insert records to Heroku Postgres database using a rails script

I need to update a dababase from an other database... For this I need to search in existing database if the records exists, if not add... One of the database is locally stored in my computer, and the other one is on heroku... But I don't know how to access heroku database from my computer to create the inserts and to query if I have to insert or not...
Any idea how can I do something like this?
You can connect via any DB tool, e.g. Oracle SQL Developer with Postgres JDBC connector, to a Heroku Postgres DB. The parameters are listed in the GUI of postgres.heroku.com for your instance.