带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=#