17. CREATE TABLE products (
????id integer NOT NULL,
????title character varying(255),
????description text,
????price numeric(10,2)
);
18. CREATE TABLE users (
????id integer NOT NULL,
?????rst_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
);
20. データ型
Data types
INSERT INTO purchases VALUES (
2, 2, '{{11.0, 1.0, 4.99}}', now()
);
21. その他の言语
Other languadges
bigint polygon money
timestamp date booleaninterval
tz smallint array integer UUID
serial bytea char
line numeric
inet cidr point circle
time text ?oat
macaddr timetz enum
varchar tsquery XML
path tsvector timestamp box
22. その他の言语
Other languadges
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;
23. その他の言语
Other languadges
FOREACH x SLICE 1 IN ARRAY $1
LOOP
s := s + (x[2] * x[3]);
END LOOP;
RETURN s;
24. その他の言语
Other languadges
python pgsql
ruby j lolcode
lua V8 R
scheme
tcl SQL psm Java
sh php javascript
25. エクステンション
Extention
CREATE EXTENSION hstore;
CREATE TABLE users (
id integer NOT NULL,
?rst_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
);