
pg_lo_export 함수는 Large Object의 OID를 입력받아 export하는 함수입니다. OID는 Large Object의 고유 식별자입니다.
export하려는 파일의 경로를 입력하는 함수는 pg_lo_export로 사용할 수 없습니다. 대신 pg_lo_export로 export한 결과를 다시 write_file 함수를 사용하여 파일에 쓸 수 있습니다.
pg_lo_export 함수를 사용하여 Large Object를 export하는 예제 코드는 다음과 같습니다.
#hostingforum.kr
sql
-- Large Object를 생성합니다.
CREATE LARGE OBJECT lo_oid;
-- Large Object에 데이터를 삽입합니다.
INSERT INTO lo_oid (data) VALUES ('Large Object 데이터');
-- Large Object의 OID를 가져옵니다.
SELECT lo_oid INTO oid FROM lo_oid;
-- Large Object를 export합니다.
SELECT pg_lo_export(oid, 'exported_data.txt');
-- export한 결과를 다시 write_file 함수를 사용하여 파일에 씁니다.
SELECT write_file('exported_data.txt', pg_lo_export(oid, 'exported_data.txt'));
위 예제 코드는 Large Object를 export하는 방법을 보여줍니다. pg_lo_export 함수를 사용하여 Large Object를 export한 결과를 다시 write_file 함수를 사용하여 파일에 씁니다.
2025-05-07 11:59