Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Heroku Postgres Webinar

Heroku Postgres Webinar

Craig Kerstiens

August 23, 2012
Tweet

More Decks by Craig Kerstiens

Other Decks in Programming

Transcript

  1. CREATE  TABLE  products  (        id  integer  NOT

     NULL,        title  character  varying(255),        description  text,        price  numeric(10,2) );
  2. CREATE  TABLE  users  (        id  integer  NOT

     NULL,        first_name  character  varying(50),        last_name  character  varying(50),        email  character  varying(255),        data  hstore,        created_at  timestamp  without  time  zone,        updated_at  timestamp  without  time  zone,        last_login  timestamp  with  time  zone );
  3. CREATE  TABLE  purchases  (        id  integer  NOT

     NULL,        user_id  integer,        items  decimal(10,2)  [][],        occurred_at  timestamp );
  4. CREATE  TABLE  purchases  (        id  integer  NOT

     NULL,        user_id  integer,        items  decimal(10,2)  [][],        occurred_at  timestamp );
  5. CREATE  TABLE  purchases  (        id  integer  NOT

     NULL,        user_id  integer,        items  decimal(10,2)  [][],        occurred_at  timestamp ); items[x][0] = item_id items [x][1] = qty items [x][2] = price
  6. Data  Types smallint bigint integer numeric float serial money char

    varchar text bytea timestamp timestamptz date time timetz interval boolean enum point line polygon box circle path inet cidr macaddr tsvector tsquery array XML UUID
  7. Other  Languages CREATE  OR  REPLACE  FUNCTION  total(decimal(10,2)[][])   RETURNS  decimal(10,2)

     AS  $$ DECLARE    s  decimal(10,2)  :=  0;    x  decimal[]; BEGIN    FOREACH  x  SLICE  1  IN  ARRAY  $1    LOOP        s  :=  s  +  (x[2]  *  x[3]);    END  LOOP;    RETURN  s; END; $$  LANGUAGE  plpgsql;
  8. Other  Languages FOREACH  x  SLICE  1  IN  ARRAY  $1  

     LOOP        s  :=  s  +  (x[2]  *  x[3]);    END  LOOP;    RETURN  s;
  9. Other  Languages python ruby pgsql SQL tcl sh R V8

    Java javascript lolcode scheme php j lua psm
  10. Extensions CREATE  EXTENSION  hstore; CREATE  TABLE  users  (    

       id  integer  NOT  NULL,        first_name  character  varying(50),        last_name  character  varying(50),        email  character  varying(255),        data  hstore,        created_at  timestamp  without  time  zone,        last_login  timestamp  without  time  zone );
  11. Extensions INSERT  INTO  users   VALUES  ( 1,   'Craig',

      'Kerstiens',   '[email protected]',   'sex  =>  "M",  state  =>  "CA"',   now(),   now() );
  12. Extensions dblink hstore citext ltree isn cube pgcrypto tablefunc uuid-ossp

    earthdistance trigram fuzzystrmatch pgrowlocks pgstattuple btree_gist dict_int dict_xsyn unaccent
  13. Learn  More Try  It  free:      https://postgres.heroku.com Code:  

                         https://github.com/craigkerstiens/postgres-­‐demo Survey:                http://bit.ly/herokupostgressurvey [email protected]    |    [email protected]