Table 「func2.sample」

testdb=# \d sample
                        Table "func2.sample"
  Column   |         Type          | Collation | Nullable | Default 
-----------+-----------------------+-----------+----------+---------
 no        | integer               |           |          | 
 item_name | character varying(20) |           |          | 
 price     | integer               |           |          | 
testdb=# CREATE OR REPLACE FUNCTION sample_func(INTEGER) RETURNS SETOF VARCHAR(20) AS $$
testdb$# SELECT item_name FROM sample WHERE price > $1;
testdb$# $$ LANGUAGE SQL;
CREATE FUNCTION
testdb=# \df
                              List of functions
 Schema |    Name     |    Result data type     | Argument data types | Type 
--------+-------------+-------------------------+---------------------+------
 func2  | sample_func | SETOF character varying | integer             | func
(1 row)
testdb=# ALTER FUNCTION sample_func(INTEGER) OWNER TO user1;
ALTER FUNCTION
testdb=# ALTER FUNCTION sample_func(INTEGER) RENAME TO sample_funcA;
ALTER FUNCTION
testdb=# \df sample_func;
                       List of functions
 Schema | Name | Result data type | Argument data types | Type 
--------+------+------------------+---------------------+------
(0 rows)

■CREATE FUNCTION
CREATE [OR REPLACE] FUNCTION 関数名([引数の型]) RETURNS [SETOF] 戻り値の型 AS $$ 処理内容 $$ LANGUAGE 使用言語 [引数NULLの挙動] [実行権限];

この記事が気に入ったらサポートをしてみませんか?