COPY keyword


Flow chart showing the syntax of the COPY keyword


Copies data from a delimited text file into a table. Column delimiter detection is automatic.

  • If the target table exists, then the data is appended provided the file structure matches the table.
  • If the target table does not exist, then it is created using metadata derived from the file data.


  • with headers true - QuestDB will automatically assume the first row is a header.
  • with headers false - QuestDB will use schema recognition to determine whether the first rows should be used as header.

COPY requires a copy root directory which is set using the configuration key cairo.sql.copy.root in the server.conf file.


The copy directory can be on a local disk to the server, on a remote disk, or a remote filesystem. QuestDB will enforce that the tables are only written from files located in a directory relative to the copy directory. This is a security feature to disallow random file access by QuestDB.


COPY trades20191223 FROM 'C:\archive\trades\20191223.csv'
COPY with headers true
COPY trades20191223 FROM 'C:\archive\trades\20191223.csv' with headers true