search_path如何影响标识符解析和“当前模式"? [英] How does the search_path influence identifier resolution and the "current schema"

查看:96
本文介绍了search_path如何影响标识符解析和“当前模式"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以定义默认情况下在哪个架构中创建新表? (由不合格的表名"引用.)

Is it possible to define in which schema new tables get created by default? (Referred by "unqualified table names".)

我已经在Postgres中看到了有关使用搜索路径"的一些详细信息,但我认为它仅在检索数据而不是创建时起作用.

I've seen some details about using the "search path" in Postgres, but I think it only works while retrieving data, not creating.

我有一堆SQL脚本,它们创建许多表.我不想修改脚本,而是希望在默认模式下将数据库创建表设置为特定的模式-当它们具有不合格的名称时.

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.

这可能吗?

推荐答案

搜索路径的确是您想要的:

Search path is indeed what you want:

% create schema blarg;
% set search_path to blarg;
% create table foo (id int);
% \d
       List of relations
 Schema | Name | Type  | Owner 
--------+------+-------+-------
 blarg  | foo  | table | pgsql

这篇关于search_path如何影响标识符解析和“当前模式"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆