READ_FILE Function

Reads a file line-by-line and returns it in a table. This function is used in the FROM clause of a SELECT statement and can participate in joins as if it were a table.

Syntax

READ_FILE(file-path, [file-encoding])

Parameters

Return Value

A table with the following columns:
Column name Example value
number 1
line "First line of the file"

Example

-- Returns a table containing the last 50 lines
-- in "file.txt" in reverse order.
SELECT *
FROM READ_FILE('C:\temp\file.txt')
ORDER BY number DESC
LIMIT 50;

-- Returns a table containing the contents of
-- "ShiftJIS.txt", which is read using the Japanese
-- Shift-JIS encoding (code page 932).
SELECT * FROM READ_FILE('C:\ShiftJIS.txt', 932);