to_regdatabase()

将数据库名称转换为 OID 的函数
此条目涉及一项 PostgreSQL 功能,该功能是 PostgreSQL 19 的一部分,预计将于 2026 年底发布。

to_regdatabase() 是一个系统函数,用于将数据库名称转换为其 OID

to_regdatabase() 添加于 PostgreSQL 19

用法

to_regdatabase ( text ) → regdatabase

to_regdatabase() 等同于使用 regdatabase 对象标识符类型转换,但如果不存在匹配的数据库,它会返回 NULL 而不是引发 ERROR

变更历史

示例

to_regdatabase() 的基本用法示例

postgres=# SELECT to_regdatabase('template1')::oid;
 to_regdatabase 
----------------
              1
(1 row)

如果指定的数据库不存在,则返回 NULL

postgres=# SELECT to_regdatabase('foo')::oid IS NULL;
 ?column? 
----------
 t
(1 row)

分类

数据类型, 系统函数

另请参阅

regdatabase, to_regrole()

反馈

提交关于 "to_regdatabase()" 的任何评论、建议或更正请点击 此处