말은 거창한데..

sequence나 mysql 기준 auto increment 지정된 Pk 값을 나중에 추가해서

그 값을 넣어줄때 쓰는 방법

UPDATE table SET column = nextval('seq_name') 하면 해결!

 

정말.. SQL 문이 강력하구나.. 라는걸 느끼는 중

 

UPDATE property_pictures SET id=10000+nextval('property_gallery_id_seq');

[링크 : https://fle.github.io/reset-a-postgresql-sequence-and-recompute-column-values.html]

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

postgresql where similar to (정규표현식)  (0) 2019.09.29
update case  (0) 2019.09.26
sql group by like?  (0) 2019.09.25
postgresql select having  (0) 2019.09.24
postgresql select from , (cross join)  (0) 2019.09.24
Posted by 구차니

도대체 내가 왜이렇게 까지 욕 먹어가면서 이걸 해야하나 자괴감 들어. 라는 상태인데

 

프로젝트 총 책임이 해당 프로젝트에 대한 전체적인 비전 뿐만 아니라

코어 모듈/로직에 대한 최소한도의 구상은 가지고 있어야 한다고 생각을 하는데

그 전제 자체가 잘못된걸까?

 

그래서 큰 건 하고 나면 사람들이 관두는건가 싶기도 하네.. 후..

단지 그 위기가 나에게 찾아왔을 뿐이고

 

관두기에는 돈도 없고 다른 이만큼 주는데도 없고 고민이네..

어떻게든 버티고

내년에는 좀 정신을 가다듬을수 있도록 작은 규모로만 해야 하려나..

 

아니면 처음부터 개입을 해서 올해처럼 안되게 하는게 더 나은걸려나?

'개소리 왈왈 > 직딩의 비애' 카테고리의 다른 글

멘탈 와사삭  (4) 2019.10.11
피곤..  (2) 2019.10.03
체불 퇴직금 신고  (0) 2019.09.19
추석 전날 피곤..  (2) 2019.09.12
새로운 달의 시작  (0) 2019.09.01
Posted by 구차니

문법은 미지원

유사하게 case로 구현은 가능하나

추후 값에 따라 자동으로 유사한것 끼리 묶는건 불가능 할 듯

 

[링크 : https://stackoverflow.com/questions/6101404/sql-group-by-like]

Posted by 구차니
Linux2019. 9. 25. 18:05

wc -l 로 총 몇개가 매칭되었는지 숫자 쓰는데 쓸만한 녀석

 

grep -o 'needle' file | wc -l

[링크 : https://unix.stackexchange.com/questions/6979/count-total-number-of-occurrences-using-grep]

 

+

2019.12.16

정규표현식으로 해서 매치되는 부분만 출력하라는 의미로

-E -o 옵션을 사용함

grep -Eo ‘[[:digit:]]{1,3}[.][[:digit:]]{1,3}[.][[:digit:]]{1,3}[.][[:digit:]]{1,3}’ dnsmasq.log

[링크 : https://medium.com/@alinos/grep-deep-하게-사용하기-기존-blog-에서-이전-d9b120b872a5]

'Linux' 카테고리의 다른 글

grep -v (invert match)  (0) 2019.11.01
서비스 등록 오류  (0) 2019.10.10
screen 명령어와 함께 실행하기  (0) 2019.09.23
screen 스크롤하기  (0) 2019.09.23
csv에서는 awk 보단 cut  (0) 2019.09.05
Posted by 구차니

having 은 조건에 만족하지 않는 그룹 rows를 제거한다. HAVING은 WHERE과는 다르다: WHERE는 GROUP BY의 적용 전에 개별 rows를 필터하는 대신 HAVING는 GROUP BY에 의해 생성된 group rows를 필터한다.

(해석은 하는데 무슨 뜻이여...

일단은 생성하고 나서 하나하나 생성하냐, 아니면 그룹으로 묶이는 애들 레벨에서 미리 처리하냐 차이인가?)

HAVING Clause

The optional HAVING clause has the general form

where condition is the same as specified for the WHERE clause.

HAVING eliminates group rows that do not satisfy the condition. HAVING is different from WHERE: WHERE filters individual rows before the application of GROUP BY, while HAVING filters group rows created by GROUP BY. Each column referenced in condition must unambiguously reference a grouping column, unless the reference appears within an aggregate function or the ungrouped column is functionally dependent on the grouping columns.

The presence of HAVING turns a query into a grouped query even if there is no GROUP BY clause. This is the same as what happens when the query contains aggregate functions but no GROUP BY clause. All the selected rows are considered to form a single group, and the SELECT list and HAVING clause can only reference table columns from within aggregate functions. Such a query will emit a single row if the HAVING condition is true, zero rows if it is not true.

Currently, FOR NO KEY UPDATE, FOR UPDATE, FOR SHARE and FOR KEY SHARE cannot be specified with HAVING.

[링크 : https://www.postgresql.org/docs/9.5/sql-select.html]

Posted by 구차니

mysql 쪽에서는 당연히 쓰는거긴 한데.. postgresql 에서도 , 로 list를 적어 주면

자동으로 cartesian product(cross join)으로 결과를 내준다고 한다.

갑자기 cross join이 inner join인지 헷갈리네...

FROM Clause

The FROM clause specifies one or more source tables for the SELECT. If multiple sources are specified, the result is the Cartesian product (cross join) of all the sources. But usually qualification conditions are added (via WHERE) to restrict the returned rows to a small subset of the Cartesian product.

[링크 : https://www.postgresql.org/docs/9.5/sql-select.html#SQL-FROM]

 

 

+

inner join과 cross join은 다른듯

join_type

One of

  • [ INNER ] JOIN

  • LEFT [ OUTER ] JOIN

  • RIGHT [ OUTER ] JOIN

  • FULL [ OUTER ] JOIN

  • CROSS JOIN

[링크 :https://www.postgresql.org/docs/9.5/sql-select.html]

 

일단은.. cross join에 where를 주면 inner join이 되는건가? 좀 헷갈리네..

Join 종류

 설명

 Cross Join

 Outer Node 의 각 row 에 대해 Inner Node 의 모든 row가 결합되어 반환

 Inner Join

 Outer Node 의 각 row 에 대해 Inner Node 의 모든 row 중 Join 조건을 만족하는 row 에 대해서만 결합되어 반환

 Equi Join

 조건의 연산자가 = 인 경우
 Non Equi Join  조건의 연산자가 = 가 아닌 경우

[링크 : https://mozi.tistory.com/69]

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

sql group by like?  (0) 2019.09.25
postgresql select having  (0) 2019.09.24
postgresql transaction begin / commit / rollback  (0) 2019.09.24
sql 문 계산하기  (0) 2019.09.24
string_agg() + COALESCE() + DISTINCT  (0) 2019.09.23
Posted by 구차니

BEGIN; 이 프로시저의 시작인줄 알았는데..

트랜잭션의 시작이었구나..

 

rollback을 위해서는 savepoint를 만들어 놔야하고

문제가 없으면 commit; 으로 transaction을 완료하면 된다.

BEGIN;
UPDATE accounts SET balance = balance - 100.00
    WHERE name = 'Alice';
SAVEPOINT my_savepoint;
UPDATE accounts SET balance = balance + 100.00
    WHERE name = 'Bob';
-- oops ... forget that and use Wally's account
ROLLBACK TO my_savepoint;
UPDATE accounts SET balance = balance + 100.00
    WHERE name = 'Wally';
COMMIT;

[링크 : https://www.postgresql.org/docs/8.3/tutorial-transactions.html]

 

근데.. 이렇게 하면 WAL 로 미친듯이 써질려나?

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

postgresql select having  (0) 2019.09.24
postgresql select from , (cross join)  (0) 2019.09.24
sql 문 계산하기  (0) 2019.09.24
string_agg() + COALESCE() + DISTINCT  (0) 2019.09.23
join where와 on  (0) 2019.09.18
Posted by 구차니
Programming/node.js2019. 9. 24. 17:53

테스트용 was나 하나 짜볼까나...

 

[링크 : https://araikuma.tistory.com/459]

 

+ 2019.12.10

[링크 : https://node-postgres.com/]

'Programming > node.js' 카테고리의 다른 글

node.js JWT with refresh token  (0) 2019.12.10
node.js synchornous file write  (0) 2019.11.06
json2csv / node.js 에서 NULL 값 출력하기  (0) 2019.09.18
js nested function과 변수 scope  (0) 2019.09.15
node.js util.format / sprintf?  (0) 2019.09.10
Posted by 구차니

값이 integer면 - 해서 계산해도 된다.

우옹.. 신기하당...

 

[링크 : https://blog.naver.com/kimnx9006/220573722518]

Posted by 구차니
개소리 왈왈/컴퓨터2019. 9. 24. 14:13

회사에서 주인 없는 후지츠 U1010과 빌립 S5 발견

 

 

둘다 배터리 어댑터 없어서 이래저래 사야 하는데 후지츠 꺼는 옥션에서 1.5만에 어댑터 발견

하지만 배터리는 너무 오래된 녀석이라 없는듯 한데..

 

일단은 1.8인치 EIDE 하드..

어디서 본 것 같은 사이즈라서 예전글 보니 2710p의 하드가 ZIF EIDE 타입 하드.. 케이블 문제로 쉽진 않을듯 하니 고민..

 

멀 하든 돈 낭비에 시간낭비 일거 같은데.. 왜이렇게 이거 탐나냐.. ㅠㅠ

나온지도 12년이 된 박물관으로 가야할 녀석인데 말이야... ㅠㅠ

 

[링크 : https://katastrophos.net/.../installing-ubuntu-10-10-maverick-meerkat-on-fujitsu-u820-u2010-u2020/]

[링크 : http://www.kpug.kr/kpugfreeboard/973625]

'개소리 왈왈 > 컴퓨터' 카테고리의 다른 글

viliv S5 i-LOG  (2) 2019.09.28
계륵과 딜레마  (4) 2019.09.27
z68 보트 메모리 슬롯 불량?  (0) 2019.09.22
ADATA SSD toolbox  (0) 2019.07.14
아내의 첫(?) SSD 경험  (4) 2019.07.07
Posted by 구차니