什么是高级?这就叫高级—openGauss(101)

17 阅读1分钟

#openGauss #入门 #安装 #数据库 #开源

知识来源:docs-opengauss.osinfra.cn/zh/

  • MOVE语句的使用。

    --开始一个事务。
    openGauss=# START TRANSACTION;
    START TRANSACTION
    
    --定义一个名为cursor1的游标。
    openGauss=# CURSOR cursor1 FOR SELECT * FROM customer_t1;
    DECLARE CURSOR
    
    --忽略游标cursor1的前3行。
    openGauss=# MOVE FORWARD 1 FROM cursor1;
    MOVE 1
    
    --抓取游标cursor1的前2行。
    openGauss=# FETCH 2 FROM cursor1;
     c_customer_sk | c_customer_id | c_first_name | c_last_name | amount
    ---------------+---------------+--------------+-------------+--------
              3769 | hello         |              |             |
              6885 | maps          | Joes         |             |   2200
    (2 rows)
    
    
    --关闭游标。
    openGauss=# CLOSE cursor1;
    CLOSE CURSOR
    
    --结束一个事务。
    openGauss=# END;
    COMMIT
    

#openGauss #入门 #安装 #数据库 #开源

知识来源:docs-opengauss.osinfra.cn/zh/