修改postgresql的自动提交

默认,postgresql是自动提交的,可以避免自动提交
1)使用begin;命令
  示例:
postgres=# begin;
BEGIN
postgres=# insert into test values(2,2);
INSERT 0 1
postgres=# select * from test;
 id | name
----+------
  1 |
  1 |    2
  2 |    2
(3 行记录)


postgres=# rollback;
ROLLBACK
postgres=# select * from test;
 id | name
----+------
  1 |
  1 |    2
(2 行记录)

2)还可以直接关闭自动提交的功能
\set AUTOCOMMIT off
示例:
postgres=# \set AUTOCOMMIT off
postgres=#
postgres=#
postgres=# insert into test values(2,2);
INSERT 0 1
postgres=# select * from test;
 id | name
----+------
  1 |
  1 |    2
  2 |    2
(3 行记录)


postgres=# rollback;
ROLLBACK
postgres=# select * from test;
 id | name
----+------
  1 |
  1 |    2
(2 行记录)

你可能感兴趣的:(postgresql,Oracle)