使用 lolor
演示 lolor 大对象创建、查询、导入和删除操作的 SQL 示例。
LOLOR 1.3.0-dev 上游参考。Mimus 19.0.1 已整合的 pgEdge 扩展为 Spock 5.0.15;LOLOR 在 Mimus 上的兼容性尚待验证。
以下命令示例演示如何使用 lolor:
-- Create a large object with no data and return the oid:
lolor_db=# SELECT lo_creat (-1);
lo_creat
----------
1100433
(1 row)
-- Querying the lolor schema for related stats:
lolor_db=# SELECT * FROM lolor.pg_largeobject_metadata where oid = 1100433:
oid | lomowner | lomacl
---------+----------+--------
1100433 | 10 |
(1 row)
-- Creating an empty large object with oid 200000:
lolor_db=# SELECT lo_create (200000);
lo_create
-----------
200000
(1 row)
-- Get related stats
lolor_db=# SELECT * FROM lolor.pg_largeobject_metadata where oid = 200001:
oid | lomowner | lomacl
--------+----------+--------
200001 | 10 |
(1 row)
-- Import an operating system file as a large object:
lolor_db=# SELECT lo_import ('/etc/os-release');
lo_import
-----------
1100449
(1 row)
-- Return information about the large object:
lolor_db=# SELECT * FROM
lolor.pg_largeobject where loid = 1100449;
loid | pageno | data
1100449 | 0 | \x5052455454595f4e414d453d2244656269616e20474e552f4c696e75782031322028626f6f6b776f726d29220a4e414d453d2244656269616e20474e552f4c696e7578220a56455
253494f4e5f49443d223132220a56455253494f4e3d2231322028626f6f6b776f726d29220a56455253494f4e5f434f44454e414d453d626f6f6b776f726d0a49443d64656269616e0a484f4d455f55524c3d
2268747470733a2f2f7777772e64656269616e2e6f72672f220a535550504f52545f55524c3d2268747470733a2f2f7777772e64656269616e2e6f72672f737570706f7274220a4255475f5245504f52545f5
5524c3d2268747470733a2f2f627567732e64656269616e2e6f72672f220a
(1 row)
-- Unlink a large object:
lolor_db=# SELECT lo_unlink (1100449);
lo_unlink
-----------
1
(1 row)上游原文 · 1548836b0df0 · Copyright (c) 2024–2026, pgEdge, Inc. PostgreSQL 许可证。
中文译校:PGSTY 社区。
本页改编自 pgEdge LOLOR (1548836b0df0),Copyright (c) 2024–2026, pgEdge, Inc.,依 PostgreSQL License 授权,详见归属声明与修改历史。
本页为译文,如有出入以原文为准。