在PostgreSQL中找到主机名 [英] Find the host name in postgresql
问题描述
是否可以使用MS SQL Server这样的简单语法
Is it possible with easy syntax like MS SQL Server do
SELECT HOST_NAME()
吗?
我读过一些文章,但没有结果!
in postgresql 9.3.2? I have read some articles but no result !
推荐答案
不,默认版本没有。但是,使用新的本机函数扩展PostgreSQL很容易,并且有人已经做到了: http://pgxn.org/dist / hostname / 。
No, the default build doesn't have that. It is easy however to extend PostgreSQL with new native functions and someone already did it: http://pgxn.org/dist/hostname/ .
另一种方法是安装附加的db语言(PostgreSQL就是这样,您可以选择使用任意语言代替pl / pgsql),并使用该语言自己的功能来执行此操作。有例如pl / python( http://www.postgresql.org/docs/9.1 /static/plpython-funcs.html )和pl / perl( http://www.postgresql.org/docs/9.1/static/plperl-trusted.html -另请参阅有关受信任和不受信任语言的讨论。
Another way would be to install an additional db language (PostgreSQL is great like that - you have the option of using arbitrary languages instead of pl/pgsql) and use the language's own functions to do that. There are e.g. pl/python (http://www.postgresql.org/docs/9.1/static/plpython-funcs.html) and pl/perl (http://www.postgresql.org/docs/9.1/static/plperl-trusted.html -- see also the discussion about trusted and untrusted languages).
这篇关于在PostgreSQL中找到主机名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!