具有函数 gen_random_uuid() 的 PostgreSQL 查询不适用于 Windows

标签 postgresql pgcrypto

我有以下创建表的查询,

CREATE TABLE IF NOT EXISTS company (
    id uuid CONSTRAINT companyid PRIMARY KEY DEFAULT gen_random_uuid(),
    name varchar(128) NOT NULL,
    db_uri varchar(255) NOT NULL,
    c_uri varchar(255) NOT NULL,
    date_c timestamp DEFAULT now(),
    date_m timestamp DEFAULT now()
    ) WITH (fillfactor=90);

当我通过 pgAdminIII 运行它时出现以下错误。

ERROR:  function gen_random_uuid() does not exist
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
********** Error **********
ERROR: function gen_random_uuid() does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.

我创建了一个扩展 pgcrypto,因为它包含 gen_random_uuid() 函数定义,但这也没有帮助。

我在 MAC 上运行了相同的脚本,一切正常。

我正在使用 PostgreSQL 9.3。

最佳答案

问题出在 PostgreSQL 的版本上。

在 PostgreSQL 9.4 中,pgcrypto 具有 gen_random_uuid() 函数。

安装了新版本,一切都很好!

http://www.postgresql.org/docs/9.3/static/pgcrypto.html

http://www.postgresql.org/docs/9.4/static/pgcrypto.html

关于具有函数 gen_random_uuid() 的 PostgreSQL 查询不适用于 Windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33361743/

相关文章:

ruby-on-rails - 为什么新服务器上有 "PG::UndefinedFunction: ERROR: function gen_random_uuid() does not exist"而旧服务器上没有?

python - 从 python 绑定(bind)到 pgcrypto

asp.net - 如何在没有用户名或密码的情况下配置与 Azure Database for PostgreSQL 灵活服务器的连接?

postgresql - postgres容器在容器内部没有任何关系

Hibernate 模式参数在@SequenceGenerator 注释中不起作用

sql - 是否可以在同一个查询中创建和使用窗口函数?

ruby-on-rails - postgres 9.4,pgcrypto 0.4.1,rails 4.2.0,ruby 2.2.0,引用预期的字符串,得到 Arel::Nodes::BindParam

PostgreSQL 如何连接间隔值 '2 days'

php - 无法使用 AES-256-CBC 中的 pgcrypto 解密,但 AES-128-CBC 可以

postgresql - PostgreSQL 中的自动密码散列