pg_basebackup requires database to be offline for a valid backup? False
SSL can be enforced for selective clients based on host or IP? True
Which configuration files restricts and configrues host based access? pg_hba.conf
Which command modifies Database settings at the cluster level? ALTER SYSTEM
What command is used to initialise a new cluster? initdb
pg_dump backup allows us to restore data to point of end of backup time? false
the most appropriate command for creating a database cluster.
initdb --encoding=EUC_JP --no-locale
$pg_restore -U postgres -d database1 database1.dump
This command can not be executed unless the postmaster is running.
Select two SQL statements which abort a transaction.
ROLLBACK, ABORT
CREATE FUNCTION get_head(BOOLEAN)
RETURNS TEXT
LANGUAGE sql
CALLED ON NULL INPUT
AS
'SELECT val FROM t WHERE $1 OR id > 0 ORDER BY id LIMIT 1;';
create taable book (
id varchar(21) ,
title text not null,
price int ,
unique(id),
check(price > 0);
insert into book values ('4-12345-678-9', 'SQL book', 2300)
insert into book (title, price) values('PostgreSQL', 3000);
update book set id='4-12345-678-9' where id is NULL;
delete from book where price < 0;
while executing, select the first location that generates an error
$pg_dump postgres > pgsql
$vacuumdb -az
recovers unused areas from all of the databases.
collects statistical information related to the table content for all of the databases
create or replace function get_file_list(text, boolean)
returns setof text --문자열(text)의 목록을 반환
language c --C 언어로 작성된 외부 함수
strict --인자 중 하나라도 NULL이면 함수 자체를 실행하지 않고 NULL을 반환합니다. 즉, NULL-safe shortcut
security definer --함수를 만든 사람(또는 지정된 권한을 가진 사용자)의 권한으로 실행됩니다.
as 'myfuncs.so'; C 코드가 컴파일된 공유 라이브러리(.so 파일) 경로
select * from get_file_list('/home/user', true);
PostgreSQL에서 호출될 때 C로 작성된 외부 라이브러리(myfuncs.so)의 함수를 실행하여 text 형식의 결과를 여러 개 반환합니다
$pg_dump -b -F c b > d
-b large objects (BLOBs)도 포함해서 백업하겠다는 의미입니다. (--blobs와 동일)
-F c 백업 포맷을 custom 형식으로 지정합니다. (--format=custom)
b 백업하려는 데이터베이스 이름입니다.
> d 백업 결과를 파일 d에 저장합니다. 즉, 파일 리디렉션입니다.
PostgreSQL은 다양한 언어에서 사용할 수 있는 드라이버와 API를 제공합니다:
VACUUM FULL in PostgreSQL version 9.0:
VACUUM FULL은 테이블과 인덱스를 모두 재작성합니다.
즉, 사용되지 않는 공간을 회수하고 디스크 공간을 실제로 줄이며, 인덱스도 함께 재구성(shrink) 됩니다.
결과적으로 성능 향상에 도움이 될 수 있습니다.
PostgreSQL 9.0에서도 VACUUM FULL은 테이블과 인덱스를 shrink하는 기능을 가지고 있었습니다.
https://www.krdump.com/POSTGRESQL-CE.PGCES-02.Premium.Version.html#exams