search-path

How to check if a table exists in a given schema

你离开我真会死。 提交于 2019-11-25 22:31:20
问题 Postgres 8.4 and greater databases contain common tables in public schema and company specific tables in company schema. company schema names always start with \'company\' and end with the company number. So there may be schemas like: public company1 company2 company3 ... companynn An application always works with a single company. The search_path is specified accordingly in odbc or npgsql connection string, like: search_path=\'company3,public\' How would you check if a given table exists in

How does the search_path influence identifier resolution and the “current schema”

末鹿安然 提交于 2019-11-25 21:43:12
问题 Is it possible to define in which schema new tables get created by default? (Referred by \"unqualified table names\".) I\'ve seen some details about using the \"search path\" in Postgres, but I think it only works while retrieving data, not creating. I have a bunch of SQL scripts, which create many tables. Instead of modifying the scripts, I want to set the database create tables in a specific schema by default - when they have unqualified names. Is this possible? 回答1: Search path is indeed