如何在 Ubuntu 10.04 上使用 PostgreSQL 8.4.4 生成 uuid?

发布于 2024-09-25 17:22:58 字数 471 浏览 0 评论 0原文

我正在 Ubuntu 10.04 上运行 PostgreSQL 8.4.4。

我正在尝试生成 uuid 但找不到方法。

我确实在 /usr/share/postgresql/8.4/contrib/uuid-ossp.sql 中有 uuid-ossp.sql

当我尝试时,我得到的是:

postgres=# SELECT uuid_generate_v1();
ERROR:  function uuid_generate_v1() does not exist
LINE 1: SELECT uuid_generate_v1();
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

知道吗?

I am running PostgreSQL 8.4.4 with Ubuntu 10.04.

I am trying to generate uuid but can't find a way to do it.

I do have the uuid-ossp.sql in /usr/share/postgresql/8.4/contrib/uuid-ossp.sql

When I try this is what I get :

postgres=# SELECT uuid_generate_v1();
ERROR:  function uuid_generate_v1() does not exist
LINE 1: SELECT uuid_generate_v1();
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Any idea ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故事与诗 2024-10-02 17:22:58

contrib 中的内容不会自动运行。您必须自己运行它来安装功能。我不知道 8.4 版本,但在 8.3 版本中,它似乎只安装每个数据库,因此打开您在 psql 中使用的数据库并发出命令 \i /usr/share/ postgresql/8.4/contrib/uuid-ossp.sql

The stuff in contrib aren't run automatically. You have to run it yourself to install the functions. I don't know about the 8.4 version, but in the 8.3 version it appears to only install it per-database, so open up the database you're using in psql and issue the command \i /usr/share/postgresql/8.4/contrib/uuid-ossp.sql

秋凉 2024-10-02 17:22:58

我在 PostgreSQL 游记中看到了这一点。它需要 pgcrypto contrib 模块。

CREATE OR REPLACE FUNCTION generate_uuid() RETURNS UUID AS
$
SELECT ENCODE(GEN_RANDOM_BYTES(16), 'hex')::UUID
$ LANGUAGE SQL IMMUTABLE;

I saw this in my PostgreSQL travels. It requires the pgcrypto contrib module.

CREATE OR REPLACE FUNCTION generate_uuid() RETURNS UUID AS
$
SELECT ENCODE(GEN_RANDOM_BYTES(16), 'hex')::UUID
$ LANGUAGE SQL IMMUTABLE;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文