Search code examples
postgresqlintegernumericcreate-tablesqldatatypes

PostgreSQL (Create Table)


I am trying to create a table. One of the columns; "start_lng" meaning start longitude, includes a negative decimal number (-87.223655662). As I create my columns what kind of data type would this categorize as. I was going to use INT but then I realized that can only include whole numbers. Then I thought about NUMERIC but I am confused on whether or not that can be negative or not. I have attached my code below. Please help.

CREATE TABLE may_2021 (
ride_id INTEGER NOT NULL,
rideable_type VARCHAR(50) NOT NULL,
started_at TIMESTAMP NOT NULL,
ended_at TIMESTAMP NOT NULL,
ride_length INTERVAL(1000) NOT NULL,
day_of_week INTEGER NOT NULL,
start_station_name TEXT,
start_station_id VARCHAR(75),
end_station_name TEXT,
end_station_id VARCHAR(75),
start_lat NUMERIC(15,15) NOT NULL,
start_lng NUMERIC(15,15) NOT NULL,
end_lat NUMERIC(15,15) NOT NULL,
end_lng NUMERIC(15,15) NOT NULL,
member_casual TEXT
)

Solution

  • yes ,numeric data type allows negative values .