PostgreSQL SELECT, FROM, WHERE

PostgreSQL에서 SELECT, FROM, WHERE 사용하기 PostgreSQL은 강력하고 유연한 오픈 소스 관계형 데이터베이스 관리 시스템입니다. SQL (Structured Query Language)은 데이터베이스와 상호 작용하기 위해 사용되는 표준 언어이며, SELECT, FROM, WHERE 절은 SQL 쿼리에서 가장 기본적이고 중요한 요소들입니다. 이 글에서는 PostgreSQL에서 SELECT, FROM, WHERE 절을 사용하여 데이터를 조회하는 방법에 대해 설명하겠습니다. 1. SELECT 절 SELECT 절은 데이터베이스에서 조회할 열(컬럼)을 지정합니다. 예를 들어, employee 테이블에서 모든 열을 조회하려면 다음과 같이 작성할 수 있습니다: SELECT * FROM employee; 여기서 *는 모든 열을 의미합니다....

Postgres install with source 소스 코드로 설치하기

PostgreSQL 소스코드로 설치하기 Download Github git clone https://github.com/postgres/postgres.git # 설치하고자 하는 버전으로 변경 cd postgres git checkout REL_16_3 File Browser https://www.postgresql.org/ftp/source/ 여기서 원하는 버전 다운받으면 된다. wget https://ftp.postgresql.org/pub/source/v16.3/postgresql-16.3.tar.gz tar xvfz postgresql-16.3.tar.gz Compile ./configure --prefix=/home/postgres/pgsql --enable-cassert --enable-debug CFLAGS="-ggdb -Og -g3 -fno-omit-frame-pointer" make sudo make install –prefix 에는 설치할 경로를 지정해주면 된다. 기본 DB 설치 cd /home/postgres/pgsql/bin ./initdb -D ../data PostgreSQL 가동 -D 는 데이터 폴더, -l은 로그 파일 cd /home/postgres/pgsql/bin ./pg_ctl start -D ....

PostgreSQL pg_hint_plan

pg_hint_plan pg_hint_plan은 PostgreSQL에 쿼리를 전송할 때 쿼리와 함께 hint를 제공해 원하는 쿼리 플랜을 통해 쿼리가 실행되도록 만들 수 있다. pg_hint_plan_github github installation에 나와있는 대로 설치를 하면 된다. 쿼리 전 나는 pg_hint_plan을 사용하기 전에 아래 sql을 입력하고 활용한다. load 'pg_hint_plan'; set pg_hint_plan.message_level to notice; SET pg_hint_plan.debug_print TO on; 그러면 아래처럼 쿼리 힌트를 제공했을 때 어떤 힌트가 사용되고 있는지 알 수 있다. NOTICE: available indexes for IndexScan NOTICE: pg_hint_plan: used hint: not used hint: duplication hint: error hint: Hint list 아래 표를 github hint_list 여기서 확인할 수 있다....

Postgres 명령어 모음

postgres 명령어 postgres 재시작 sudo sudo systemctl restart postgresql 테이블 이름 바꾸기 ALTER TABLE table_name RENAME TO new_table_name; 인덱스 조회 SELECT * FROM pg_indexes WHERE tablename = 'table_name';