PostgreSQL(16)
-
Postgresql 백터 DB 생성(pgvector)
postgres 계정으로 app DB에 pgvector 생성CREATE EXTENSION IF NOT EXISTS vector;app 계정으로 app DB에 테이블 및 필요한 객체 생성 CREATE TABLE ai_memory ( id BIGSERIAL PRIMARY KEY, user_id TEXT NOT NULL, -- 사용자 구분 kind TEXT NOT NULL, -- fact|preference|profile|task|note 등 content TEXT NOT NULL, -- 메모리 본문 source T..
2025.09.14 -
Postgresql pgvector 설정
-- 설치 가능한지 확인SELECT * FROM pg_available_extensions WHERE name='vector';-- 이미 설치됐는지 확인SELECT * FROM pg_extension WHERE extname='vector';-- 설치CREATE EXTENSION IF NOT EXISTS vector;
2025.09.14 -
PostgreSQL WITH RECURSIVE 배열로 데이터 전달하기
WITH RECURSIVE category_hierarchy AS ( -- Base case: Select root nodes SELECT id, name, parent_id, ARRAY[name] AS path, -- Start hierarchy path as an array ARRAY[x,y,width,height] AS rectData, -- Start hierarchy path as an array 1 AS level FROM categories WHERE parent_id IS NULL UNION ALL -- Recursive case: Append child nodes to hierarchy ..
2025.01.30 -
PostgreSQL WITH RECURSIVE과 ARRAY를 사용하여, hierarchy 구조 테이블 데이터 보여주기
쿼리WITH RECURSIVE category_hierarchy AS ( -- Base case: Select root nodes SELECT id, name, parent_id, ARRAY[name] AS path, -- Start hierarchy path as an array 1 AS level FROM categories WHERE parent_id IS NULL UNION ALL -- Recursive case: Append child nodes to hierarchy SELECT c.id, c.name, c.parent_id, ch.path ..
2025.01.29 -
PostgreSQL outer join
Left outer join: a 기준으로 다 나옴SELECT a.id AS table_a_id, a.name AS table_a_name, b.id AS table_b_id, b.description AS table_b_descriptionFROM table_a aLEFT OUTER JOIN table_b b ON a.id = b.a_id;table_a_id | table_a_name | table_b_id | table_b_description-----------+-------------+------------+----------------------1 | Apple | 1 | Fruit2 | Carrot ..
2025.01.29 -
PostgreSQL 'desc'도 키워드임
컬럼명에 사용하면 에러 발생함
2025.01.04