ERROR: function addgeometrycolumn does not exist: When trying to import file into POSTGIS database by QGIS DB Manager - postgresql

I am trying to import a shapefile via db manager in QGIS to my POSTGIS database but I get an error, that I do not know to resolve:
ERROR: function addgeometrycolumn(unknown, unknown, unknown, integer, unknown, integer) does not exist
LINE 1: SELECT AddGeometryColumn('demoschema','Bomen',NULL,31370,'MU...
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
So what do I need to do?

Without postgis extension in postgresSQL, if you try to add any spatial layers to postgresSQL , you get above error.
In pgadmin right click on extensions and check whether postgis extension is saved or not.
if in extensions postgis option is absent ,you can follow these steps to
install postgis in postgres https://www.youtube.com/watch?v=afK8GWpb8RU

The 3rd parameter is the column name, which is Null in your case. Make sure you specify it in the interface

Related

Why I still can not use Postgis function after install the Postgis extension

Well as clear as the title, my college set up the database and said that already add Postgis extension to the database.
However, I still can not use the function of Postgis
ERROR: function routing.st_distancesphere(unknown, text) does not exist Hint: No function matches the given name and argument types. You might need to add explicit type casts. Position: 47
You can run the following to confirm if you have postgis installed
SELECT PostGIS_version();
If not installed then you can install it with
CREATE EXTENSION postgis;

Can't use ltree data type in postgresql

According to https://dzone.com/articles/installing-the-postgres-ltree-extension, ltree is installed and enabled on my computer. But when I try to make a table with a column of type ltree in Postbird, it says 'type "ltree" does not exist'. This makes no sense. Please help.
Only execute this command in psql or some postgresql's sql client:
CREATE EXTENSION ltree;

Alter Type in PgSQL to rename attribute not working

I am trying to rename an attribute of a Type in PgSQL using following Alter command
ALTER TYPE typeName
RENAME ATTRIBUTE attrNameOld TO attrNameNew
CASCADE
PgSQL version is 9.5, running on Ubuntu 16.04
However, I receive following error on my Pgsql CLI
ERROR: relation "<typeName>" does not exist
Please help. Thanks.
So, I can't rename an Attribute in PostgreSQL version <10. Thanks to Stephen for sharing the stackoverflow answer.
Alternatives are available though
Remove the Type. Create anew with right Values, and update Table references
Update Catalogs

PostGIS installed, but unable to select version or add geography columns

I've got an existing Postgres 9.6 database on Google Cloud that has the PostGIS extension enabled, however whenever I try to create a table with a column with the geography type or select the PostGIS version I get an error.
For creating the geography column the error is non-descriptive — just an arrow pointing to the word geography in the following statement
create table place(coordinate geography(POINT,4326));
The version error looks as follows:
select postgis_full_version();
ERROR: could not access file "$libdir/postgis-2.3": No such file or directory
CONTEXT: SQL statement "SELECT postgis_lib_version()"
PL/pgSQL function postgis_full_version() line 22 at SQL statement
The create extension statement confirms it is already installed though e.g
create extension postgis;
error: the extension already exists
I've tried running these commands as the postgres user and as another user who's been granted permissions on the database in question but neither seem to work. Any help would be appreciated.
It's simpler than you think:
Your hosting privider has goofed up the PostGIS installation.
It looks like the file is really missing, or something else on the operating system level is misconfigured.
You should gripe at Google.

function makepoint postgresql 9.1 error postgis

Migrating postgres 8.4 to 9.1 and moving my project to a new server I get this error
ERROR: function makepoint(unknown, unknown) does not exist LINE 4: distance_sphere(makepoint('14.2995419','41.0310868'),mak... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Googling I saw that could be a problem with postgis ...
then I have followed this guide
http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS20Ubuntu1204src and I installed everything on the server ...
Nothing works ... and I'm in danger of becoming insane ...
Does anyone know how to fix it!?
As pointed out previously, these functions were previously called "makepoint" and "distance_sphere", but later renamed with a "ST_" prefix (ST = "spatial type").
A really simple solution is to add the legacy.sql functions to either your template_postgis (if used) or your target database using something like:
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/legacy.sql
From the error it would seem that you are enclosing your points in quotes, hence the complaint about unknown, unknown. ST_Makepoint will expect two double precision numbers as input. You should also prefix all spatial functions with ST_, as has been stated in the comments.
If you run the following from a psql prompt:
\df ST_MakePoint
you will see the 3 versions that are supported, for 2, 3 and 4 dimensions, all taking doubles.
For example:
select st_distance_sphere(st_makepoint(14.2995419,41.0310868), st_makepoint(15.2995419,40.0310868)) as dist;
returns 139665.10 m
For what is is worth, the ST_ is considered standard's compliant. Oracle uses ST_ before all its spatial functions, as does Postgres/Postgis, MySQL supports both ST_ and just straight function names and Microsoft decided to drop the underscore altogether when they implemented spatial sql in SQL Server 2008, so you have STUnion, for example.