replace(original, needle, replace)
to_char(date, 'YYYY/MM/DD'); to_char(time, 'HH:MI:SS');
to_char('1970-01-01'::date + (unixtime || 's')::interval, 'YYYY-MM') from test;
extract(''field'' from ''column'')
extract(hour from timestamp)
extract(year from date)
select text from note where text ~ 'Apple';
select text from note where lower(text) ~ 'apple';
select text from note where text ILIKE 'apple';
ジャンル:PostgreSQL
SELECT relname, reltuples as rows, (relpages * 8192) as bytes FROM pg_class order by bytes desc;
=> SELECT relname, reltuples as rows, (relpages * 8192) as bytes FROM pg_class order by bytes desc; relname | rows | bytes ---------------------------------+--------+----------- hoge_history | 534201 | 157196288 access_history | 44502 | 14344192 user_access | 36037 | 9109504 user_info | 11368 | 4456448 (中略)
=> DELETE FROM hoge_history; DELETE 535056
=> DELETE FROM hoge_history; DELETE 535056 => SELECT relname, reltuples as rows, (relpages * 8192) as bytes FROM pg_class order by bytes desc; relname | rows | bytes ---------------------------------+--------+----------- hoge_history | 534201 | 157196288 (中略)
=> VACUUM FULL hoge_history ; VACUUM => SELECT relname, reltuples as rows, (relpages * 8192) as bytes FROM pg_class where relname = 'hoge_history'; relname | rows | bytes --------------+------+------- hoge_history | 0 | 0 (1 row)