云数据库 GAUSSDB-EXECUTE:示例

时间:2024-11-13 14:46:46

示例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
--创建表reason。
gaussdb=# CREATE TABLE reason ( 
    CD_DEMO_SK          int NOT NULL,
    CD_GENDER           varchar(10),
    CD_MARITAL_STATUS   varchar(10)
);

--为一个INSERT语句创建一个预备语句然后执行它。
gaussdb=# PREPARE insert_reason(int,varchar(10),varchar(10)) AS INSERT INTO reason VALUES($1,$2,$3);
gaussdb=# EXECUTE insert_reason(52, 'AAAAAAAADD', 'reason 52'); 

--查询数据。
gaussdb=# SELECT * FROM reason;
 cd_demo_sk | cd_gender  | cd_marital_status 
------------+------------+-------------------
         52 | AAAAAAAADD | reason 52
(1 row)

--删除表reason。
gaussdb=# DROP TABLE reason;
support.huaweicloud.com/centralized-devg-v8-gaussdb/gaussdb-42-0639.html