AUTOCOMMIT自动提交该参数要大写才能生效,否则即使小写autocommit改为off,但小写的autocommit并不生效

来源:互联网 发布:q叔淘宝店叫什么名字 编辑:程序博客网 时间:2024/05/22 05:13
highgo=# \! cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.5 (Santiago)


highgo=# select version();
              version               
------------------------------------
 HighGo Database 3.1.4 Linux 64-bit
(1 row)


highgo=# show autocommit;
 autocommit 
------------
 on
(1 row)


highgo=# \echo :AUTOCOMMIT
on
highgo=# \set autocommit off         --此时执行后\echo :autocommit显示为on;此时标记为自定义变量autocommit
highgo=# show autocommit;
 autocommit 
------------
 on
(1 row)


highgo=# \echo :AUTOCOMMIT
on
highgo=# \set AUTOCOMMIT off      ---AUTOCOMMIT要完全大写才能生效
highgo=# show autocommit;
 autocommit 
------------
 on
(1 row)


highgo=# \echo :AUTOCOMMIT
off




使用show命令是查询数据库中的参数值,大小写效果一样:
highgo=# show autocommit;
 autocommit 
------------
 on
(1 row)


highgo=# show AUTOCOMMIT;
 autocommit 
------------
 on
(1 row)


highgo=# set AUTOCOMMIT TO on;
SET
highgo=# set AUTOCOMMIT TO oFF;
错误:  SET AUTOCOMMIT TO OFF 不再被支持
highgo=# set AUTOCOMMIT TO off;
错误:  SET AUTOCOMMIT TO OFF 不再被支持
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
highgo=# select version();
              version               
------------------------------------
 HighGo Database 3.1.4 Linux 64-bit
(1 row)


highgo=# \set autocommit on
highgo=# \echo :autocommit
on
highgo=# show autocommit;
 autocommit 
------------
 on
(1 row)


highgo=# \set autocommit off    --此时执行后\echo :autocommit显示为OFF
highgo=# show autocommit;
 autocommit 
------------
 on                        -->pg中此处show的结果不显示修改后的值(显示默认值on),需要使用如下echo命令
(1 row)


highgo=# \echo :autocommit
off




+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
highgo=#  \echo :AUTOCOMMIT
on
highgo=# \set autocommit off  
highgo=# show autocommit;
 autocommit 
------------
 on
(1 row)


highgo=# \echo :AUTOCOMMIT
on
highgo=# \echo :autocommit
off
highgo=# SELECT * FROM TEST;
 id | name 
----+------
  3 | 
  4 | 
(2 rows)


highgo=# insert into test values (5);
INSERT 0 1
highgo=# SELECT * FROM TEST;
 id | name 
----+------
  3 | 
  4 | 
  5 | 
(3 rows)


highgo=# \echo :autocommit    --此处虽然小写autocommit的值改成了off,但并不生效;实际会话中还是为ON
off
highgo=# \echo :AUTOCOMMIT
on