무슨.. 맨날맨날 기절

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

회사 정전으로 인해  (0) 2019.10.13
멘탈 와사삭  (4) 2019.10.11
현타 거나하게 오네..  (4) 2019.09.26
체불 퇴직금 신고  (0) 2019.09.19
추석 전날 피곤..  (2) 2019.09.12
Posted by 구차니

array 안에서는 select 문을 통해 다른 값들을 받아 하나의 필드로 출력을 해준다.

개꿀! (unnest로 풀면되지!)

 

The result I get is:

 +-----------------------+
 | ?column?              |
 +-----------------------+
 | 15:00:00 Dissertation |
 | 17:00:00 Dinner       |
 | 23:00:00 Sleep        |
 +-----------------------+
Now that I have my rows, I can turn them into an array.  Now, the ARRAY function needs to be invoked via a SELECT.  Thus, using ARRAY means that we’re using a subselect.  The inner SELECT is what we did above.  The outer one is just our call to ARRAY:

SELECT ARRAY(SELECT meeting_at::time || ' ' || description 
FROM Appointments 
WHERE meeting_at::date = '2014-may-23'
ORDER BY meeting_at);
And sure enough, we get a one-row, one-column result:

 +--------------------------------------------------------------+
 | array                                                        |
 +--------------------------------------------------------------+
 | {"15:00:00 Dissertation","17:00:00 Dinner","23:00:00 Sleep"} |
 +--------------------------------------------------------------+

[링크 : https://lerner.co.il/2014/05/23/turning-postgresql-rows-arrays-array/]

Posted by 구차니

헐.. INNER , OUTER 보다 보니

LEFT JOIN은 어느걸까 했는데 OUTER일 줄이야..

 

INNER, OUTER 부터 다시 공부해야겠다. ㅠㅠ

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

Posted by 구차니

select 문만 쓰다가 update를 join을 통해 하려니 신기한 느낌?

update 문에 table이 하나 있으니 FROM 으로 다른 테이블을 정해주면 자연스럽게(?) join이 된다.

 

UPDATE tb1

SET col2 = tb2.col22

FROM tb2

WHERE tb1.col1 = tb2.col21 

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

Posted by 구차니

select로 추려낸 결과를 다른 select - where 문에서 쓰기 위한 방법

 

[링크 : https://stackoverflow.com/questions/1136380/sql-where-in-clause-multiple-columns]

 

+

2019.10.04

라는데.. 굳이 이걸 써야 하나 싶긴하네

select * from where (val1_upper, val2_upper) in (select val1,val2 from something)

Posted by 구차니

temporary file leak: File 4 still referenced

 

아.. 먼가 불안한 경고다.. 

일단 급한건 아니니 나중에 봐야지..

 

[링크 : https://dba.stackexchange.com/questions/112079/slow-query-performance-due-to-temporary-file]

Posted by 구차니

regexp_matches()는 여러개가 매칭될수 있어서 array()로 리턴하는데

{} 로 쌓여 있어서 그걸 벗기기 위해서는 unnest()를 하는게 가장 간단한데..

 

select 까진 문제없으나..

udpate 시에는 multiple row가 나올 녀석은 아예 배제가 되니 주의

 

[링크 : https://stackoverflow.com/questions/10593400/remove-braces-from-regular-expression-result]

Posted by 구차니
Programming/xml2019. 9. 29. 23:03

boolean() 으로 특정 element를 조회하면 될 듯?

 

[링크 : https://stackoverflow.com/questions/5689966/how-to-check-if-an-element-exists-in-the-xml-using-xpath]

 

+

2019.12.17

옛날 글이라 그런가 링크가 깨졌네

The boolean function converts its argument to a boolean as follows:

  • a number is true if and only if it is neither positive or negative zero nor NaN

  • a node-set is true if and only if it is non-empty

  • a string is true if and only if its length is non-zero

  • an object of a type other than the four basic types is converted to a boolean in a way that is dependent on that type

[링크 : https://stackoverflow.com/questions/5689966/how-to-check-if-an-element-exists-in-the-xml-using-xpath]

[링크 : http://www.w3.org/TR/xpath/#function-boolean] << 옛날 링크

 

Rules

The function computes the effective boolean value of a sequence, defined according to the following rules. See also Section 2.4.3 Effective Boolean Value XP31.

  • If $arg is the empty sequence, fn:boolean returns false.

  • If $arg is a sequence whose first item is a node, fn:boolean returns true.

  • If $arg is a singleton value of type xs:boolean or a derived from xs:boolean, fn:boolean returns $arg.

  • If $arg is a singleton value of type xs:string or a type derived from xs:string, xs:anyURI or a type derived from xs:anyURI, or xs:untypedAtomic, fn:boolean returns false if the operand value has zero length; otherwise it returns true.

  • If $arg is a singleton value of any numeric type or a type derived from a numeric type, fn:boolean returns false if the operand value is NaN or is numerically equal to zero; otherwise it returns true.

[링크 : https://www.w3.org/TR/xpath-functions-31/#func-boolean] << 새로운 링크?

 

'Programming > xml' 카테고리의 다른 글

XML DOM과 SAX  (0) 2019.12.01
xpath 복수개의 attribute 동시에 만족하는 항목 찾기  (0) 2019.09.14
xsd minOccurs, maxOccurs  (0) 2019.09.11
xpath count()  (0) 2019.09.09
xpath xsi  (0) 2019.08.12
Posted by 구차니

unnest를 사용하니 ,로 구분된 리스트를 여러개의 열로 나눌수 있었다.

string_to_array()의 반대 개념이라고 하면 되려나?

 

regexp_split_to_table() 도 사용할 수 있으나 regexp의 cost가 비싼 편이라 추천은 안하는 듯

[링크 : https://stackoverflow.com/questions/29419993/split-column-into-multiple-rows-in-postgres]

  [링크 : https://www.postgresql.org/docs/current/functions-string.html#FUNCTIONS-STRING-OTHER]

 

+

예제에 따라 다르지만 select에서 써도 되고 from에서 lateral join으로 구현해도 되고

어느게 cost가 낮을려나?

[링크 : https://www.postgresql.org/docs/9.2/functions-array.html]

[링크 : https://wwwi.tistory.com/350]

 

+

 

Posted by 구차니

 

The operator ~~ is equivalent to LIKE, and ~~* corresponds to ILIKE. There are also !~~ and !~~* operators that represent NOT LIKE and NOT ILIKE, respectively. All of these operators are PostgreSQL-specific.

[링크 : https://www.postgresql.org/docs/9.3/functions-matching.html]

 

SQL> select * from test where x ~ '[0-9]+';  -- "~" 는 "similar to" 의미입니다.

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

Posted by 구차니