select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

FUNCTIONS / SYSTEM ADMINISTRATION FUNCTIONS

Returns all or part of a text file, starting at the given byte offset, returning at most length bytes (less if the end of file is reached first).

Signatures & examples

pg_read_file ( filename text [, offset bigint, length bigint ] [, missing_ok boolean ] ) → text
Returns all or part of a text file, starting at the given byte offset, returning at most length bytes (less if the end of file is reached first). If offset is negative, it is relative to the end of the file. If offset and length are omitted, the entire file is returned. The bytes read from the file are interpreted as a string in the database's encoding; an error is thrown if they are not valid in that encoding.
Version history 5
  1. PG 15 → 16changed
  2. PG 12 → 13changed
  3. PG 10 → 11changed
  4. PG 9.4 → 9.5changed
  5. PG 9.0 → 9.1changed

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source