使用 MySQL 时在 SQL Developer 中禁用自动提交
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17826779/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Disable autocommit in SQL Developer when using MySQL
提问by Michael
I'd like to connect to a MySQL server with Oracle SQL Developer, but with autocommit disabled. By default, all MySQL connections have autocommit enabled, which is rather odd.
我想使用 Oracle SQL Developer 连接到 MySQL 服务器,但禁用了自动提交。默认情况下,所有 MySQL 连接都启用了自动提交,这很奇怪。
The global setting in SQL Developer is unchecked, and
SQL Developer 中的全局设置未选中,并且
set autocommit=0;
results in the error
导致错误
set autocommit script command forced off, as connection level autocommit is on.
设置自动提交脚本命令强制关闭,因为连接级别自动提交已打开。
In the connection's settings are no other options besides hostname, port and a drop down box for database selection.
在连接的设置中,除了主机名、端口和用于数据库选择的下拉框之外,没有其他选项。
I'm using SQL Developer 3.2.10 with latest JDBC connector, 5.1.
我将 SQL Developer 3.2.10 与最新的 JDBC 连接器 5.1 一起使用。
采纳答案by diadyne
You will run into an error if you try and use
如果您尝试使用,您将遇到错误
start transaction;
-- Your SQL statements
commit;
...out of the box on a MySQL database in SQLDeveloper (as Michael mentioned in a comment to another answer.)
...在 SQLDeveloper 中的 MySQL 数据库上开箱即用(正如迈克尔在对另一个答案的评论中提到的那样。)
In order to get around this error that Michael referenced in his comment you can use the following hint:
为了解决迈克尔在他的评论中提到的这个错误,你可以使用以下提示:
/*sqldev:stmt*/start transaction;
-- Your SQL statements
/*sqldev:stmt*/commit;
Found this information here.
在此处找到此信息。
回答by rob2universe
In Oracle SQL Developer 4the setting has moved:
在 Oracle SQL Developer 4 中,设置已移动:
Tools > Preferences > Database > Advanced > Autocommit
工具 > 首选项 > 数据库 > 高级 > 自动提交
Default is off.
默认关闭。
Alternative:
选择:
set autocommit off;
回答by Uttam Kumar
Outils-->Preferences-->Fenetre SQL--> Validation automatique de transactions SQL uncheck the check box
Outils-->Preferences-->Fenetre SQL-->Validation automatique de transactions SQL取消勾选
回答by Narendra Reddy
You can turn on AutoCommit by clicking on Tools | Preferences Open the Database Tree select Worksheet parameters Check on the Autocommit in SQL Worksheet box
您可以通过单击“工具” | “自动提交”来打开“自动提交”。首选项 打开数据库树 选择工作表参数 检查 SQL 工作表中的自动提交框
回答by Melinda
Turn off the auto commit option in SqlDeveloper. Go to Tools -> Preferences -> Database -> ObjectViewer Parameters and uncheck the box Set Auto Commit On.
关闭 SqlDeveloper 中的自动提交选项。转到工具 -> 首选项 -> 数据库 -> ObjectViewer 参数并取消选中设置自动提交框。
回答by Tantowi Mustofa
enclose the commands with 'start transaction' and 'commit'. mysql turned off auto-commit on 'start transaction' until 'commit' or 'rollback' is issued
用“开始事务”和“提交”将命令括起来。mysql 在“开始事务”时关闭自动提交,直到发出“提交”或“回滚”
回答by Jhonny Lins
set autocommit=false;--or true
--comment required/**/
/*sqldev:stmt*/start transaction;
--your sql
/*sqldev:stmt*/commit;
/*sqldev:stmt*/rollback;
回答by Harsh Gurudiwan
connect sqlplus as sysadmin and type command "SET AUTOCOMMIT OFF" it is off as command. and if u want to check it is off or not the type command "show autocommit" and it show like "autocommit OFF"
以系统管理员身份连接 sqlplus 并键入命令“SET AUTOCOMMIT OFF”,它作为命令关闭。如果你想检查它是否关闭,输入命令“show autocommit”,它显示为“autocommit OFF”