분류 전체보기

    [2014.05.23] Convert Format Type

    SELECT MAX(TO_NUMBER(myTextColumn, '99999')) From Your_Table_NameManuals : http://www.postgresql.org/docs/8.2/static/functions-formatting.html C언어 에서의 Casting 이라 보면되겠다.

    [PostgreSQL] WITH 문의(Query)

    WITH는, 보다 큰 SELECT 쿼리에 사용되는 서브쿼리를 작성하는 방법을 제공합니다. 서브 질의는 종종 공통 테이블 식 즉 CTE라고 합니다만, 그 질문에만 존재하는 임시 테이블을 정의하는 것입니다. 이 특성 중 1 개의 사용법은 복잡한 질문을 단순한 부품으로 분해하는 것입니다. 예입니다.WITH regional_sales AS ( SELECT region, SUM(amount) AS total_sales FROM orders GROUP BY region ), top_regions AS ( SELECT region FROM regional_sales WHERE total_sales > (SELECT SUM(total_sales)/10 FROM regional_sales) ) SELECT region,..

    [PostgreSQL] Create/Drop/Restore 시 batch-file 만들기(환경변수설정포함)

    위 파일을 메모장으로 열어보면 알 수 있다. 1. CREATE DATABASE 시에는 CREATE DATABASE createtest WITH OWNER postgres TEMPLATE template0 ENCODING 'UTF8' TABLESPACE pg_default LC_COLLATE 'Korean_Korea.949' LC_CTYPE 'Korean_Korea.949' CONNECTION LIMIT -1" 속성들을 설정 해 줄수있다. 2. DROP DATABASE 는 간단함. 3. pg_restore 은 pg_restore -U postgres -d My_DB_Name < My_Backup_FileName.dump 위의 My_~ 는 DB이름 , Backup 해둔 DB 파일이름 을 집어 넣으면 된다. ..

    [PostgreSQL] CTID 단편화하기(?)

    postgres=# select *, ctid from t; index | ctid ------+------- 1 | (0,1) 2 | (0,2) 3 | (0,3) 4 | (0,4) (4 rows) 1번 레코드를 5번 으로 업데이트하면 postgres=# update t set index=10 where index=1; UPDATE 1 postgres=# select *, ctid from t; index | ctid ------+------- 2 | (0,2) 3 | (0,3) 4 | (0,4) 5 | (0,5) (4 rows) 이것을 다시 순서대로 해주려면 VACUUM FULL ! 하면 됩니다. postgres=# VACUUM FULL t; VACUUM postgres=# select *, ctid ..

    [종합상식] 한국사 연표

    한번쯤은 알아둬야 하지 않을까 싶어서 퍼옴..