1

I need to create 2 tables with distinct geometry.

One needs to be a table that has point information. The other needs to be a table that has line information.

They do not need to be populated as this is just a test. They just need to have the geometry column.

The code so far is:

CREATE TABLE point

CREATE TABLE line

How to add the geometry into the code?

1 Answer 1

1

The simple answer is:

create table points ( p POINT not null); 
create table lines ( l LINE not null);

Then inserts look like this:

insert into points (p) values (POINT(1.2, 123.1));
insert into lines (l) values (LINE(POINT(1.2, 123.1), POINT(-5, -123)));

You probably want to build indexes if you want to have some lookups on them. Also a primary key may be beneficial.

3
  • It created the table but doesn't have geometry column that I needed and forgot to ask. Also what do you mean by indexes? Also I thought it had something to do with Addgeometrycolumn. How can I add the geometry column?
    – Luffydude
    Commented May 27, 2016 at 16:07
  • the postgis docs for AddGeometryColumn should give you what you need.
    – rob c
    Commented May 27, 2016 at 16:22
  • Do you have an example for CIRCLE? Commented Apr 28, 2017 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.