Read and execute another SQL file.
Section: Scripting and Automation
Include another script
sql
sql
\i ./common.sqlExplanation
See summary for usage details.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Scripting and Automation
Execute script in one transaction
Wrap the script in a single transaction.
Echo hidden commands
Show underlying SQL generated by backslash commands.
Conditional blocks in psql
Use psql conditionals in interactive or scripted sessions.