Last active
December 11, 2015 04:18
-
-
Save jatorre/4543823 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://viz2.cartodb.com/api/v2/sql?api_key=XXXXXXX&q= | |
-- Example SQL to create a table named new_table. Replace new_table with whatever name you want | |
CREATE TABLE new_table | |
( | |
--Data types we recommend using: text, integer, float(8), boolean, timestamp without time zone | |
barrio text, | |
perimetro numeric, | |
area numeric, | |
comuna integer, | |
-- These fields are mandatory, do not remove | |
-- The geometry type could be MultiPolygon, MultiLineString or Point (Nothing else) | |
the_geom geometry(MultiPolygon,4326), | |
cartodb_id serial NOT NULL, | |
created_at timestamp without time zone DEFAULT now(), | |
updated_at timestamp without time zone DEFAULT now(), | |
the_geom_webmercator geometry(MultiPolygon,3857), | |
CONSTRAINT new_table_pkey PRIMARY KEY (cartodb_id) | |
) | |
WITH ( | |
OIDS=FALSE | |
); | |
--We need to create all these indexes, replace new_table for the name of your new table | |
CREATE INDEX new_table_the_geom_webmercator_idx | |
ON new_table | |
USING gist | |
(the_geom_webmercator); | |
CREATE TRIGGER cache_checkpoint | |
BEFORE INSERT OR UPDATE OR DELETE OR TRUNCATE | |
ON new_table | |
FOR EACH STATEMENT | |
EXECUTE PROCEDURE update_timestamp(); | |
CREATE TRIGGER test_quota | |
BEFORE INSERT OR UPDATE | |
ON new_table | |
FOR EACH STATEMENT | |
EXECUTE PROCEDURE check_quota(); | |
CREATE TRIGGER update_the_geom_webmercator_trigger | |
BEFORE INSERT OR UPDATE OF the_geom | |
ON new_table | |
FOR EACH ROW | |
EXECUTE PROCEDURE update_the_geom_webmercator(); | |
CREATE TRIGGER update_updated_at_trigger | |
BEFORE UPDATE | |
ON new_table | |
FOR EACH ROW | |
EXECUTE PROCEDURE update_updated_at(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment