select 로 몇개 줄이 나왔는지는 못하는것 같고(perform 해서 어떻게 받는게 가능해 보이긴 하지만)

select into나

update, insert문 등에 의해 영향을 받은(affected) 것에 대해서 출력이 되는 듯

 

GET DIAGNOSTICS integer_var = ROW_COUNT;

[링크 : https://www.postgresql.org/docs/9.0/plpgsql-statements.html]

 

변수 선언

DO $$ 
DECLARE
   varname integer := 0;
BEGIN 
   get diagnostics age = row_count;
   raise notice '%', age;
END $$;

[링크 : http://www.postgresqltutorial.com/plpgsql-variables/]

[링크 : http://www.gisdeveloper.co.kr/?p=4573]

 

+

pg 9.3 이후 부터 지원되는 듯

Allow PL/pgSQL to access the number of rows processed by COPY (Pavel Stehule)

A COPY executed in a PL/pgSQL function now updates the value retrieved by GET DIAGNOSTICS x = ROW_COUNT.

[링크 : https://stackoverflow.com/questions/16610449/get-the-count-of-rows-from-a-copy-command]

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

where 1=1  (4) 2019.08.27
join  (0) 2019.08.27
sql select if or case  (0) 2019.08.26
order by group by  (0) 2019.08.26
postgresql 정규 표현식 검색  (0) 2019.08.26
Posted by 구차니

표준 sql 에서는 if는 존재하지 않고 mysql에서만 전용 명령어로 제공하는 듯

그래서 그 대신에 case - when - then - end 구조로 처리하게 된다.

 

[링크 : https://devbox.tistory.com/entry/DBMS-CASEWHENTHEN]

 

CASE WHEN condition THEN result
     [WHEN ...]
     [ELSE result]
END

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

 

 

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

join  (0) 2019.08.27
postgresql ROW_COUNT  (0) 2019.08.27
order by group by  (0) 2019.08.26
postgresql 정규 표현식 검색  (0) 2019.08.26
sql ||과 concat()  (0) 2019.08.22
Posted by 구차니

order by로 할 걸 group by로 하는걸 고민하고 있었나..

그러니 안되지.. ㅠㅠ

 

[링크 : https://mingggu.tistory.com/83]

[링크 : https://gangnam-americano.tistory.com/25]

[링크 : https://www.popit.kr/마케터를-위한-sql-3-group-by-살펴보기/]

 

 

 

 

 

 

 

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

postgresql ROW_COUNT  (0) 2019.08.27
sql select if or case  (0) 2019.08.26
postgresql 정규 표현식 검색  (0) 2019.08.26
sql ||과 concat()  (0) 2019.08.22
pgadmin 에서 table 생성 SQL문 얻기  (0) 2019.08.20
Posted by 구차니

 

 

-- Gets zero or any spaces numbers and text characters before one R
SELECT * FROM table WHERE column ~ '^[\s\w]*[R]{1}$'

-- Gets zero or any spaces numbers and text characters after one R
SELECT * FROM table WHERE column ~ '^[R]{1}[\s\w]*$'

[링크 : https://stackoverflow.com/questions/46978821/postgres-regex-begins-with-and-ends-with]

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

sql select if or case  (0) 2019.08.26
order by group by  (0) 2019.08.26
sql ||과 concat()  (0) 2019.08.22
pgadmin 에서 table 생성 SQL문 얻기  (0) 2019.08.20
sql substring  (0) 2019.08.16
Posted by 구차니

같은건가?

 

[링크 : https://loveiskey.tistory.com/80]

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

order by group by  (0) 2019.08.26
postgresql 정규 표현식 검색  (0) 2019.08.26
pgadmin 에서 table 생성 SQL문 얻기  (0) 2019.08.20
sql substring  (0) 2019.08.16
sql 문자를 숫자로 정렬하기  (0) 2019.08.16
Posted by 구차니

database에서 우클릭후 backup 에서 schema only 로 하면

해당 데이터베이스에 있는 모든 schema, table들의 생성용 SQL이 생성된다.

 

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

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

postgresql 정규 표현식 검색  (0) 2019.08.26
sql ||과 concat()  (0) 2019.08.22
sql substring  (0) 2019.08.16
sql 문자를 숫자로 정렬하기  (0) 2019.08.16
postgresql 상속  (0) 2019.08.16
Posted by 구차니

정규표현식으로 원하는걸 잘라내려고 했는데

regexp_match 는 {}로 쌓버려서 귀찮아서 다른 방법 찾음

 

[링크 : https://codeday.me/ko/qa/20190414/329095.html]

Posted by 구차니

 

order by cast(number_string as bigint)

[링크 : https://beone.tistory.com/272]

Posted by 구차니

테이블 상속하니..

하위에서 값을 넣으니 부모에게도 그 값이 들어가는데

sequence는 안건드리니까 부모쪽 sequence는 증가되지 않는다.

 

아무튼.. pgadmin에서 상속하니 테이블 형상이 끌려와서

그냥 상속처럼 테이블 모양 끌어온다는 건가 해서 썼는데 그게 아니라 깜놀 -_-

 

[링크 : https://corekms.tistory.com/entry/table-inheritance상속]

Posted by 구차니

말이 복잡하네

insert into table select field from table

시에 insert 값으로 특정 상수를 넣는 방법인데..

해보니 걍.. insert into 안에 'fixed string' 식으로 항목하나 넣어주면 된다.

 

 

[링크 : https://stackoverflow.com/questions/30809384/combining-insert-select-with-constants/30809406]

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

sql 문자를 숫자로 정렬하기  (0) 2019.08.16
postgresql 상속  (0) 2019.08.16
pgadmin 초기 시작시 브라우저 선택  (0) 2019.08.15
postgres sequence - auto increment  (0) 2019.08.13
postgresql 변수 타입  (0) 2019.08.12
Posted by 구차니