A psql meta-command is a backslash-prefixed instruction interpreted by the psql command-line client rather than by the SQL server. It helps inspect the current connection and database objects, load scripts, and adjust result formatting. section 1.4
Common commands support connection checks, object discovery, script loading, and readable output:
- \\? lists the available psql meta-commands, while \\q terminates the connection. section 1.4
- \\conninfo displays the connected database, user, socket, and port; \\d lists tables, views, and sequences. section 1.4
- \\i executes SQL scripts from a file, allowing prepared schemas and datasets to be loaded into Postgres. section 4.3 section 9.3
- \\x on switches to expanded display for wide rows or large values; \\x off restores tabular output. section 8.3.2
Inspect and load a database
After connecting with psql, run \\conninfo to verify the session and \\d to inspect relations. To preload a schema or dataset, execute \\i /home/gaming_ddl.sql and \\i /home/gaming_data.sql, then verify the result with \\dt game.*. section 1.4 section 4.3
Listing 1.3 Connecting with psql
docker exec -it postgres psql -U postgres
Use the runnable psql connection command, then try the meta-commands at the interactive prompt. section 1.4
