ABORT

    作用等同于,早期SQL有用ABORT,现在推荐使用ROLLBACK。

    注意事项

    参数说明

    WORK | TRANSACTION

    1. openGauss=# CREATE TABLE customer_demographics_t1
    2. (
    3. CD_DEMO_SK INTEGER NOT NULL,
    4. CD_GENDER CHAR(1) ,
    5. CD_MARITAL_STATUS CHAR(1) ,
    6. CD_EDUCATION_STATUS CHAR(20) ,
    7. CD_CREDIT_RATING CHAR(10) ,
    8. CD_DEP_COUNT INTEGER ,
    9. CD_DEP_EMPLOYED_COUNT INTEGER ,
    10. CD_DEP_COLLEGE_COUNT INTEGER
    11. WITH (ORIENTATION = COLUMN,COMPRESSION=MIDDLE)
    12. ;
    13. --插入记录。
    14. openGauss=# INSERT INTO customer_demographics_t1 VALUES(1920801,'M', 'U', 'DOCTOR DEGREE', 200, 'GOOD', 1, 0,0);
    15. --开启事务。
    16. openGauss=# START TRANSACTION;
    17. --更新字段值。
    18. openGauss=# UPDATE customer_demographics_t1 SET cd_education_status= 'Unknown';
    19. --终止事务,上面所执行的更新会被撤销掉。
    20. openGauss=# ABORT;
    21. --查询数据。
    22. openGauss=# SELECT * FROM customer_demographics_t1 WHERE cd_demo_sk = 1920801;
    23. cd_demo_sk | cd_gender | cd_marital_status | cd_education_status | cd_purchase_estimate | cd_credit_rating | cd_dep_count | cd_dep_employed_count | cd_dep_college_count
    24. ------------+-----------+-------------------+----------------------+----------------------+------------------+--------------+-----------------------+----------------------
    25. 1920801 | M | U | DOCTOR DEGREE | 200 | GOOD | 1 | 0 | 0
    26. (1 row)

    相关链接

    SET TRANSACTION,,ROLLBACK