forked from Weitzman-MUSA-GeoCloud/assignment02
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_structure.sql
More file actions
43 lines (29 loc) · 1.24 KB
/
Copy pathdb_structure.sql
File metadata and controls
43 lines (29 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
This file contains the SQL commands to prepare the database for your queries.
Before running this file, you should have created your database, created the
schemas (see below), and loaded your data into the database.
Creating your schemas
---------------------
You can create your schemas by running the following statements in PG Admin:
create schema if not exists septa;
create schema if not exists phl;
create schema if not exists census;
Also, don't forget to enable PostGIS on your database:
create extension if not exists postgis;
Loading your data
-----------------
After you've created the schemas, load your data into the database specified in
the assignment README.
Finally, you can run this file either by copying it all into PG Admin, or by
running the following command from the command line:
psql -U postgres -d <YOUR_DATABASE_NAME> -f db_structure.sql
*/
-- Add a column to the septa.bus_stops table to store the geometry of each stop.
alter table septa.bus_stops
add column if not exists geog geography;
update septa.bus_stops
set geog = st_makepoint(stop_lon, stop_lat)::geography;
-- Create an index on the geog column.
create index if not exists septa_bus_stops__geog__idx
on septa.bus_stops using gist
(geog);