我有以下创建表的查询,
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()
函数。
安装了新版本,一切都很好!
关于具有函数 gen_random_uuid() 的 PostgreSQL 查询不适用于 Windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33361743/