使用函数 gen_random_uuid() 的 PostgreSQL 查询在 Windows 上不起作用

Ank*_*itG 3 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);
Run Code Online (Sandbox Code Playgroud)

当我通过 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.
Run Code Online (Sandbox Code Playgroud)

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

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

我正在使用 PostgreSQL 9.3。

Ank*_*itG 5

问题出在 PostgreSQL 版本上。

在 PostgreSQL 9.4 中,pgcryptogen_random_uuid()功能。

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

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

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