'프로그램 사용'에 해당되는 글 2290건

  1. 2019.10.29 postgresql ctid
  2. 2019.10.29 coalesce() / isnull()
  3. 2019.10.28 다른 테이블의 값을 이용하여 값 update 하기
  4. 2019.10.28 array_agg()와 unnest()
  5. 2019.10.25 postgres tde pgcrypto
  6. 2019.10.21 sql ' escape
  7. 2019.10.20 sql pivot / crosstab
  8. 2019.10.20 subquery
  9. 2019.10.18 array_agg() 여러개 컬럼 합치기
  10. 2019.10.16 postgresql vacuum

ctid는 typle id로 물리적 위치를 나타내는데 update 하면 바뀐다고 한다(oracle 등은 고정된 순서로 유지되는 듯)

[링크 : https://www.postgresdba.com/bbs/board.php?bo_table=B12&wr_id=63]

 

ctid

The physical location of the row version within its table. Note that although the ctid can be used to locate the row version very quickly, a row's ctid will change each time it is updated or moved by VACUUM FULL. Therefore ctid is useless as a long-term row identifier. The OID, or even better a user-defined serial number, should be used to identify logical rows.

[링크 : https://www.postgresql.org/docs/8.2/ddl-system-columns.html]

Posted by 구차니

postgresql 에서는 isnull 대신 coalesce()를 지원한다고 한다.

용도는... full outer join 에서 한쪽이 null일 경우 반대쪽 key를 사용하는 용도 정도?

그 외에는 어떤 용도가 있을지 모르겠다.

 

 

설명만 봐서는.. nullif가 다른 dbms의 명령어와 같아 보이는데

coalesce는 value [,...] 이기 때문에 n개에 대해서 지원을 하는 것으로 보인다.

COALESCE(value [, ...])
NULLIF(value1, value2)

[링크 : https://www.postgresql.org/docs/9.5/functions-conditional.html]

[링크 : http://www.postgresqltutorial.com/postgresql-coalesce/]

 

[링크 : https://xshine.tistory.com/205]

[링크 : https://joeylee.tistory.com/15]

Posted by 구차니

join은 번거로우니 set 에다가 select로 값을 때려 넣기라는 좋은 방법이 있었네?

 

UPDATE table1 
   SET price=(SELECT price FROM table2 WHERE table1.id=table2.id);

[링크 : https://stackoverflow.com/questions/1746125/...]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

postgresql ctid  (0) 2019.10.29
coalesce() / isnull()  (0) 2019.10.29
array_agg()와 unnest()  (0) 2019.10.28
postgres tde pgcrypto  (0) 2019.10.25
sql ' escape  (0) 2019.10.21
Posted by 구차니

이전에 만들었던것에 실수(?)를 한거 같은데..

여러가지 이유로 인해서 bigint array를 text로 저장했는데

이걸 다시 array로 돌려서 unnest() 하려면 먼가 희한하게 꼬인다.

아무튼.. 원래대로 돌릴려면

unnest(field::bigint[]) 로 하면 정상적으로 bigint형 배열로 해서 unnest()가 정상적으로 수행된다.

 

만약 아래처럼 하게 되면

unnest(string_to_array(field, ','))

{1,2} 에서

'{1'

'2}' 이런식으로 나오게 되니 주의가 필요

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

coalesce() / isnull()  (0) 2019.10.29
다른 테이블의 값을 이용하여 값 update 하기  (0) 2019.10.28
postgres tde pgcrypto  (0) 2019.10.25
sql ' escape  (0) 2019.10.21
sql pivot / crosstab  (0) 2019.10.20
Posted by 구차니

'를 문장내에서 쓰기 위해서는

' '' ' 이렇게 하면 된다.

 

'' (홀따옴표 두개)

[링크 : https://kdarkdev.tistory.com/122]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

array_agg()와 unnest()  (0) 2019.10.28
postgres tde pgcrypto  (0) 2019.10.25
sql pivot / crosstab  (0) 2019.10.20
subquery  (0) 2019.10.20
array_agg() 여러개 컬럼 합치기  (0) 2019.10.18
Posted by 구차니

요렇게 여러개에 대해서 나열된 녀석들을

 

아래처럼 바꾸어주는걸 pivot이라고 표현하는데

위의 정보는 로그라는 느낌이라면, pivor으로 표현하면 먼가 전문적인 느낌이 든다?

아무튼.. 하나의 기준(여기서는 cdate)에 하나의 값 분류로 정렬한다.. 라고 하면 맞는걸까?

[링크 : https://splee75.tistory.com/110]

 

crosstab

[링크 : https://codeday.me/ko/qa/20190307/17921.html]

[링크 : https://www.postgresql.org/docs/9.1/tablefunc.html]

[링크 : http://www.gurubee.net/article/80779]

 

+

2019.10.21

crosstab 여러가지 방식이 있으나..

crosstab('데이터','컬럼명') 으로 하는게 가장 확실한 듯?

[링크 : https://yahwang.github.io/posts/76]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

postgres tde pgcrypto  (0) 2019.10.25
sql ' escape  (0) 2019.10.21
subquery  (0) 2019.10.20
array_agg() 여러개 컬럼 합치기  (0) 2019.10.18
postgresql vacuum  (0) 2019.10.16
Posted by 구차니

여러개의 행을 돌려주는 서브쿼리라는게 이 기능에 대한 카테고리일려나?

아무튼 아무생각 없이 쓰던 select where in 이 이 구문이라니..

 

[링크 : http://www.gurubee.net/lecture/1503]

[링크 : https://subscription.packtpub.com/book/big_data_and_business_intelligence/9781783989003/1/ch01lvl1sec16/subqueries-that-return-multiple-rows]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

sql ' escape  (0) 2019.10.21
sql pivot / crosstab  (0) 2019.10.20
array_agg() 여러개 컬럼 합치기  (0) 2019.10.18
postgresql vacuum  (0) 2019.10.16
pgadmin4 분석기능  (0) 2019.10.16
Posted by 구차니

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

sql pivot / crosstab  (0) 2019.10.20
subquery  (0) 2019.10.20
postgresql vacuum  (0) 2019.10.16
pgadmin4 분석기능  (0) 2019.10.16
postgres regexp_matches() 매칭되는 것이 없을 경우  (0) 2019.10.16
Posted by 구차니

vacuum full 을 하면 db 끊고

다시 복사해서 새로운 데이터베이스로 생성하면서

용량을 줄이는 등의 최적화를 하고

 

vacuum verbose analyze 를 하면 간략하게 끊지 않고도 할 수 있다고 한다.

 

다만 디스크 스토리지 줄이는건 full만 된다고.

 

[링크 : https://blog.gaerae.com/2015/09/postgresql-vacuum-fsm.html]

[링크 : https://bstar36.tistory.com/308]

 

아래의 명령으로 자동 정리가 켜져있는지 확인가능하다고 한다.

show autovacuum;

[링크 : http://hochul.net/blog/postgresql-vacuum-optimization/?ckattempt=1]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

subquery  (0) 2019.10.20
array_agg() 여러개 컬럼 합치기  (0) 2019.10.18
pgadmin4 분석기능  (0) 2019.10.16
postgres regexp_matches() 매칭되는 것이 없을 경우  (0) 2019.10.16
sql 결과 공백 제거  (0) 2019.10.15
Posted by 구차니