如何检查自动提交是否在Postgres的psql中 [英] How to check if autocommit is on or not postgres' psql
问题描述
我正在使用postgres 9.5。如何检查自动提交功能是打开还是关闭?我尝试了 SHOW AUTOCOMMIT
的错误消息:无法识别的配置参数 autocommit ,然后执行了关闭自动提交
,然后 SHOW AUTOCOMMIT
给我空白的输出。如何确定自动提交是打开还是关闭?还可以在我的sql文件中创建数据库时/之后将其设置为关闭吗?
I am using postgres 9.5. How can I check if auto commit is on or off? I tried SHOW AUTOCOMMIT
where I got ERROR: unrecognized configuration parameter "autocommit"
then I did a \set autocommit off
and then SHOW AUTOCOMMIT
gives me blank output. How can identify if autocommit is on or off? Also can I set it to off while/after the database in created in my sql file?
推荐答案
根据这篇达斯汀·马克思文章,您可以使用:
According to this Dustin Marx article, you can use:
\echo :AUTOCOMMIT
如果希望始终禁用自动提交,则可以将set
AUTOCOMMIT off元命令添加到本地的〜/ .psqlrc
文件中。对于更全局的设置,可以将此元命令放在数据库系统配置目录中的apsqlrc文件中的
中(可以使用PostgreSQL操作系统级别的命令pg_config
定位到
- sysconfdir)。
If it's desired to "always" have autocommit disabled, the \set AUTOCOMMIT off meta-command can be added to one's local ~/.psqlrc file. For an even more global setting, this meta-command can be placed in apsqlrc file in the database's system config directory (which can be located using PostgreSQL operating system-level command pg_config --sysconfdir).
这篇关于如何检查自动提交是否在Postgres的psql中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!