User `\set` to set set a variable inside psql. Read about SQL interpolation in the manual here: - https://www.postgresql.org/docs/current/app-psql.html#APP-PSQL-INTERPOLATION Ideally, your script would read: SELECT * FROM :"my_schema".:"my_table" LIMIT 1; With schema and table double-quoted separately, for identifier-interpolation. Then set schema and table in psql without quotes like: my_db=>\set my_schema core my_db=>\set my_table product Just the bare, case-sensitive names. Finally, execute: my_db=>\i my-script.sql This way, the script is safe against SQL injection.