'2019/10/30'에 해당되는 글 2건

  1. 2019.10.30 pgcrypto 사용 예제
  2. 2019.10.30 postgresql 쿼리 수행속도 벤치마크 하기

확장기능 설치. database 하위의 extension에 pgcrypto가 추가되며

사용가능한 함수들은 public에 function 에 추가된다.

CREATE EXTENSION pgcrypto;

 

binary 값으로 나오기 때문에 encode와 decode를 이용해서 출력하도록 하는 것으로 보임

-- 암호화

select encode(encrypt(convert_to('홍길동','utf8'),'ENC_KEY','aes'),'hex');

-- 복호화

select convert_from(decrypt(decode('encrypted_value','hex'),'ENC_KEY','aes'),'utf8');

-- 암호화 된 것을 검색하기

select mem_id, convert_from(decrypt(decode(mem_name,'hex'),'ENC_KEY','aes'),'utf8') from tb_test;

[링크 : https://jully215.tistory.com/104]

 

문제는... 암호화하려면 해당 컬럼이 bytea 형식이 되어야 하는 듯?

regress=# create table demo(pw bytea);
CREATE TABLE
regress=# insert into demo(pw) values ( encrypt( 'data', 'key', 'aes') );
INSERT 0 1
regress=# select decrypt(pw, 'key', 'aes') FROM demo;
  decrypt   
------------
 \x64617461
(1 row)

regress=# select convert_from(decrypt(pw, 'key', 'aes'), 'utf-8') FROM demo;
 convert_from 
--------------
 data
(1 row)

[링크 : https://dba.stackexchange.com/questions/24370/how-to-use-aes-encryption-in-postgresql]

 

[링크 : https://www.postgresql.org/docs/9.4/pgcrypto.html]

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

array_agg에서 NULL 없애기 array_remove()  (0) 2019.11.06
drop extension  (0) 2019.11.01
postgresql 쿼리 수행속도 벤치마크 하기  (0) 2019.10.30
postgresql ctid  (0) 2019.10.29
coalesce() / isnull()  (0) 2019.10.29
Posted by 구차니

for loop로 반복하기

[링크 : https://dba.stackexchange.com/questions/42012/how-can-i-benchmark-a-postgresql-query]

 

pgbench - 말그대로 벤치마크용 유틸리티. 테이블 생성등의 성능을 테스트 하는 듯

[링크 : https://severalnines.com/blog/benchmarking-postgresql-performance]

[링크 : https://www.postgresql.org/docs/10/pgbench.html]

 

+

mysql에는 benchmark()라는 함수로 지원함(반복 명령에 대한 매크로 느낌)

[링크 : http://www.mysqlkorea.com/sub.html?mcode=develop&scode=01&lang=k&m_no=21838...]

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

drop extension  (0) 2019.11.01
pgcrypto 사용 예제  (0) 2019.10.30
postgresql ctid  (0) 2019.10.29
coalesce() / isnull()  (0) 2019.10.29
다른 테이블의 값을 이용하여 값 update 하기  (0) 2019.10.28
Posted by 구차니