psql/execute-query

Execute SQL Query

Run a SQL query from the terminal

query
execution

Command

psql -c "SELECT * FROM tablename;"

Explanation

Executes a given SQL query directly from the command line.

Examples

Query all rows from users table

psql -c "SELECT * FROM users;"