小编典典

扩展存在但 uuid_generate_v4 失败

all

在亚马逊 ec2 RDS Postgresql:

=> SHOW rds.extensions;

rds.extensions                                                                                                                                 
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 btree_gin,btree_gist,chkpass,citext,cube,dblink,dict_int,dict_xsyn,earthdistance,fuzzystrmatch,hstore,intagg,intarray,isn,ltree,pgcrypto,pgrowlocks,pg_trgm,plperl,plpgsql,pltcl,postgis,postgis_tiger_geocoder,postgis_topology,sslinfo,tablefunc,tsearch2,unaccent,uuid-ossp
(1 row)

如您所见,uuid-ossp扩展确实存在。但是,当我为 generation 调用函数时uuid_v4,它失败了:

CREATE TABLE my_table (
    id uuid DEFAULT uuid_generate_v4() NOT NULL,
    name character varying(32) NOT NULL,

);

这有什么问题?


阅读 167

收藏
2022-08-27

共1个答案

小编典典

该扩展 可用 但未 安装 在此数据库中。

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
2022-08-27