[模式名.]存储过程名介绍

最近更新时间: 2024-06-12 15:06:00

建立存储过程,模式名可以指定,也可以不指定,不指存则存放在当前模式下,如上面例子就没有指定模式名,则就存放在当前模式下,如下所示:

postgres=# select * from pg_namespace;
      nspname       | nspowner |               nspacl
--------------------+----------+-------------------------------------
 pg_toast           |       10 |
 pg_temp_1          |       10 |
 pg_toast_temp_1    |       10 |
 pg_catalog         |       10 | {postgres=UC/postgres,=U/postgres}
 public             |       10 | {postgres=UC/postgres,=UC/postgres}
 information_schema |       10 | {postgres=UC/postgres,=U/postgres}
(6 行记录)
postgres=# show search_path;
  search_path
----------------
 "$user",public
(1 行记录)
postgres=# select pg_namespace.nspname,pg_proc.prosrc from pg_proc,pg_namespace where 
pg_proc.pronamespace=pg_namespace.oid and pg_proc.proname='proc_1';
 nspname |             prosrc              
---------+---------------------------------
 public  |                                +
         | begin                          +
         |    raise notice 'Hello,TBase';+
         | end;                           +
         | 
(1 row)

因为$user模式不存在,所以存在public模式下。