OR REPLACE更新存儲介紹
更新時間 2025-02-14 10:25:06
最近更新時間: 2025-02-14 10:25:06
分享文章
本頁介紹天翼云TeleDB數據庫使用OR REPLACE更新存儲的語法。
帶OR REPLACE的作用,在建立存儲過程時若存在則替換,建立存儲時不帶 OR REPLACE關鍵字,則遇到函數已經存系統則會報錯,如下所示。
teledb=# select prosrc from pg_proc where proname='proc_1';
prosrc
--------------------------------
+
begin +
raise notice 'Hello teledb_pg';+
end; +
(1 row)
teledb=# CREATE OR REPLACE PROCEDURE proc_1() AS
$$
begin
raise notice 'Hello,teledb_pg';
end;
$$
LANGUAGE PLPGSQL;
CREATE PROCEDURE
teledb=# select prosrc from pg_proc where proname='proc_1';
prosrc
---------------------------------
+
begin +
raise notice 'Hello,teledb_pg';+
end; +
(1 row)
teledb=#
teledb=# call proc_1();
NOTICE: Hello,teledb_pg
CALL
teledb=#