Search code examples
postgresqlpostgis

PostgreSQL, Postgis geometry field


In my table (coordinates) I have x, y z coordinates, and I want to create a new colmun which contains the point.

id |x   |y   | z   |        
----------------------
1  |145 |9.6 |12.4 |

So I run the following commands:

ALTER TABLE coordinates ADD COLUMN point geometry;
UPDATE point SET = 'POINT(x y z)';

But I got this error :

<-- parse error at

Solution

  • Your UPDATE command is wrong, suspect you want something like this:

    (ST_MakePoint may not be the constructor you want, but I don't think POINT exists).

    UPDATE coordinates SET point = ST_MakePoint(x,y,z);