简体   繁体   中英

How to change default/current schema in sql

Preety basic question from my end that I unfortunately could not find an answer to. In my database I have 2 schemas with their respective tables. Schema X and schema Y. While I can simply pull the data easily from schema X with

SELECT * FROM employees

I cannot do the same with schema Y, forcing me to use

SELECT * FROM SchemaY.customers

My question is, how can I change the current or default schema from X to Y so I can query the tables without the SchemaY. in the table names begining.

Kindest

Marcin

ps: I utilize Postgres and play around in DataGrip.

Change the search path

set search_path = schemay, public;

You can also do that for your user permanently:

alter user current_user 
  set search_path = schemay, public;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM