SQLDeveloper: execute current line without highlighting

我只是一个虾纸丫 提交于 2019-12-12 07:48:38

问题


In Toad one can easily execute current line without highlighting it. Let say, you have a worksheet like this:

select * from item -- cursor here


select * from product

When I click on CTRL+Enter I want only the line where the cursor is to be executed. In SQLDeveloper, if there is no second line, CTRL+Enter works as I want. Basically, I want to do the same as described here, but for some reason, I can't find the Tools -> Preferences -> Window Types -> SQL Window and check "AutoSelect statement" in the version of the SQLDeveloper I am using: 4.0.0.13, build Build MAIN: 13.80.

Seems like, this functionality is taken out in the 4.x of Oracle SQLDeveloper?


回答1:


If you have a block (anonymous or such) of code before your sql statement, make sure to end with forward slash, for the CTRL+enter to work.

CTRL+Enter on the select sysdate statement below works in second example below, but not on the first example.

Example 1:

begin
NULL;
end;

select sysdate from dual; -- press CTRL+Enter on this statement

Example 2:

begin
NULL;
end;
/

select sysdate from dual; -- press CTRL+Enter on this statement



回答2:


For those who also wonder about the same thing, here is what you gotta do. End each statement with ; and it works.

select * from item
;

select * from product;



回答3:


Actually the best option is mentioned here : http://forums.allroundautomations.com/ubb/ubbthreads.php?ubb=showflat&Number=46683

1) Press Ctrl-F8 when the cursor is on the statement. Now only the current statement is executed. You can assign a different key through the preferences (Tools > Preferences > Key Configuration > "SQL Window: Execute current statement").

2) Enable the "AutoSelect statement" preference (Tools > Preferences > SQL Window). Now the standard execute function will automatically select the current statement under the cursor and execute it. To execute multiple statements you now have to explicitly select them first in the editor, or use Ctrl-F8.




回答4:


I also ran into a similar situation where Ctrl+Enter shortcut stopped working for executing any statement and had to highlight the entire statement for executing it.

How it worked: (i) By removing/commenting out all the comments in the worksheet i.e. just have only the Sql statements in the worksheet, if at all you have put any statements/comments in the worksheet for your understanding, just disable those and then Ctrl+Enter starts working.

PS: I didn't do any other changes apart from this to make this shortcut work.

Cheers



来源:https://stackoverflow.com/questions/21730693/sqldeveloper-execute-current-line-without-highlighting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!