#title PostgreSQL 메모
[[TableOfContents]]

==== distinct on ====
{{{
--title별 가장 큰 customer_id와 fname 조회
select distinct on (title) title , customer_id, fname
from (select * from customer order by title, customer_id desc) t
}}}

==== Run external script in psql ====
{{{
psql mydb < dump.sql
psql mydb -f dump.sql

psql -d mydb -f dump.sql

or

psql -f dump.sql mydb


psql [database name] < [script name]

testdb=# \i [script name]
}}}

==== link ====
 * http://database.sarang.net/?criteria=pgsql
 * [http://old.storytotell.org/blog/2009/08/12/postgresql-84-windowing-functions.html PostgreSQL 8.4: Windowing Functions]
 * http://people.freebsd.org/~kris/scaling/
 * [http://www.redhat.com/pdf/rhel/bmsql-postgres-sqlsrvr-v1.0-1.pdf 벤치마크(postgresql8.3.8 vs sql server 2008 r2]