vim-sql-workbench.txt 50.0 KB
Newer Older
C
Cosmin Popescu 已提交
1 2 3 4 5
vim-sql-workbench.txt

==============================================================================
CONTENTS                                            *vim-sql-workbench-contents*

C
Cosmin Popescu 已提交
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
1. Tutorial.........................................|vim-sql-workbench-tutorial|
2. Introduction.................................|vim-sql-workbench-introduction|
3. Requirements.................................|vim-sql-workbench-requirements|
4. Connecting to a DBMS.................|vim-sql-workbench-connecting_to_a_dbms|
5. The database explorer...............|vim-sql-workbench-the_database_explorer|
6. The SQL buffer.............................|vim-sql-workbench-the_sql_buffer|
7. SQL commands.................................|vim-sql-workbench-sql_commands|
8. Searching.......................................|vim-sql-workbench-searching|
9. Exporting.......................................|vim-sql-workbench-exporting|
10. Sessions........................................|vim-sql-workbench-sessions|
11. Variables......................................|vim-sql-workbench-variables|
12. Commands........................................|vim-sql-workbench-commands|
13. Settings........................................|vim-sql-workbench-settings|
14. Screen shots................................|vim-sql-workbench-screen_shots|

==============================================================================
TUTORIAL                                            *vim-sql-workbench-tutorial*

The following documentation is quite long. If you don't want to read through
it, here is the quick start:

*   install  from here (http://www.sql-workbench.net/)
*   install your 'jdbc' driver for your database see
    here (http://www.sql-workbench.net/)
*   open a terminal window
*   open vim

Running sql queries against a DBMS:

*   go to an sql statement
*   in normal mode, do '<C-@>' (this is 'ctrl' + 'space')

Opening a database explorer

Note:

*   '<my-profile>' is the name of a database profile create in
    (see here (http://www.sql-workbench.net/manual/profiles.html))

For more detailed explanations, please continue reading this material.
C
Cosmin Popescu 已提交
46 47 48 49 50 51 52 53

==============================================================================
INTRODUCTION                                    *vim-sql-workbench-introduction*

This is an implementation of SQL Workbench/J (http://www.sql-workbench.net/)
in VIM. It works with any DBMS supported by  (PostgreSQL,
Oracle, SQLite, MySQL, SQL Server etc.). See the complete list
here (http://www.sql-workbench.net/databases.html).
C
Cosmin Popescu 已提交
54 55 56

You can connect to any DBMS directly from VIM.

C
Cosmin Popescu 已提交
57
Features:
C
Cosmin Popescu 已提交
58

C
Cosmin Popescu 已提交
59 60 61 62 63 64 65 66 67
*   database explorer (e.g.: table lists, procedures list, views list, triggers
    list), extensible (you can have your own objects list)
*   SQL buffer with performant autocomplete
*   export any sql statement as 'text', 'sqlinsert', 'sqlupdate',
    'sqldeleteinsert', 'xml', 'ods', 'html', 'json'
*   search in object source
*   search in table or views data
*   asynchronous (you can execute any command asynchronous)
*   fully customizable
C
Cosmin Popescu 已提交
68 69 70

CONTENTS:

C
Cosmin Popescu 已提交
71 72 73 74 75 76 77 78 79
1.  Requirements
2.  Connecting to a DBMS
3.  The database explorer
4.  The SQL Buffer
5.  SQL commands
6.  Searching
7.  Exporting
8.  Sessions
9.  Variables
C
Cosmin Popescu 已提交
80 81 82 83
10. Commands
11. Settings
12. Screen shots

C
Cosmin Popescu 已提交
84 85
==============================================================================
REQUIREMENTS                                    *vim-sql-workbench-requirements*
C
Cosmin Popescu 已提交
86

C
Cosmin Popescu 已提交
87 88 89 90 91 92
*   'Vim' compiled with 'python' support
*   'Python' installed on the machine
*    installed on the machine
*   Optional: [](https://github.com/tpope/vim-dispatch) plugin
    installed.
*   'VIM' started in server mode
C
Cosmin Popescu 已提交
93

C
Cosmin Popescu 已提交
94 95 96
Of course you need VIM 7 or above. You also need [](http://www.sql-workbench.net/) installed on your computer. It is
platform independent, since  is written in JAVA and it should
work anywhere where VIM works.
C
Cosmin Popescu 已提交
97 98

Before getting started, you have to set the 'g:sw_exe' vim variable. The
C
Cosmin Popescu 已提交
99
default value is 'sqlwbconsole.sh'. If you have  in your PATH,
C
Cosmin Popescu 已提交
100 101 102 103 104 105 106
then you can skip this step. Otherwise, just set the value of the variable to
point to your 'sqlwbconsole' file. If you are on Windows, it should be
'sqlwbconsole.exe'.

Also, if you are on Windows, you have to set the 'g:sw_tmp' value in your
'vimrc'. The default value is '/tmp'.

C
Cosmin Popescu 已提交
107 108 109 110 111 112 113
The communication with the DBMS is made through the 'sqlwbserver.py' script, that
you can find in the 'resources/py' folder of the plugin. This is a 'python'
script (hence the need to have 'python' installed on the machine) and it will
spawn a 'sqlwbconsole' instance in memory and then open a port on which will
listen for requests. After this, whenever you want to send a command to the
DBMS from 'VIM', the plugin will connect on the specified port, send the
command and retrieve the result which will be displayed in 'VIM'.
C
Cosmin Popescu 已提交
114

C
Cosmin Popescu 已提交
115
In order to work properly, you should keep the settings on default. Settings
C
Cosmin Popescu 已提交
116 117
like 'workbench.console.script.showtime' could affect the functionality of
.
C
Cosmin Popescu 已提交
118

C
Cosmin Popescu 已提交
119 120 121
Note:

Please note that the last version of the 'sqlwbserver.py' script is not
C
Cosmin Popescu 已提交
122
compatible with  before build 118. To use it with a previous
C
Cosmin Popescu 已提交
123 124 125 126 127 128
build, you will have to use the  parameter. Also, f you want to use a
version of  prior to 118, you have to set the 'vim' variable
'g:sw_use_old_sw' to '1'.

==============================================================================
CONNECTING TO A DBMS                    *vim-sql-workbench-connecting_to_a_dbms*
C
Cosmin Popescu 已提交
129 130 131 132

First of all, you need to open have a 'sqlwbserver' running in memory. There
are two ways to run a server.

C
Cosmin Popescu 已提交
133 134
------------------------------------------------------------------------------
STARTING A SERVER FROM VIM        *vim-sql-workbench-starting_a_server_from_vim*
C
Cosmin Popescu 已提交
135

C
Cosmin Popescu 已提交
136
For this you need to have the  plugin installed. If you want to
C
Cosmin Popescu 已提交
137 138 139
start the server from 'vim', you can call the command 'SWServerStart' with the
port on which the server will listen. Also, you can choose a profile for the
new connection. If you don't choose a profile now, you will have to execute
C
Cosmin Popescu 已提交
140 141
'WbConnect' (http://www.sql-workbench.net/manual/wb-commands.html#command-connect)
in order to connect to a database.
C
Cosmin Popescu 已提交
142

C
Cosmin Popescu 已提交
143
For example: .
C
Cosmin Popescu 已提交
144

C
Cosmin Popescu 已提交
145 146
------------------------------------------------------------------------------
STARTING A SERVER FROM COMMAND LINE *vim-sql-workbench-starting_a_server_from_command_line*
C
Cosmin Popescu 已提交
147

C
Cosmin Popescu 已提交
148 149 150 151
If you don't want or you can't install the  plugin, you can
always start a server from command line. From your terminal, you need to
run the 'resources/py/sqlwbserver.py' script. For a list of parameters you can
do . The following parameters are mandatory:
C
Cosmin Popescu 已提交
152

C
Cosmin Popescu 已提交
153
*   The path to your 'sqlwbconsole' executable ('-c').
C
Cosmin Popescu 已提交
154 155 156 157 158

The default port on which the server will listen is 5000. You can change this
with the '-o' parameter.

Please note that a server handles only one 'sqlwbconsole' instance, which is
C
Cosmin Popescu 已提交
159 160 161 162
not multi threading, so also the server is not multi-threading. Since a
command sent to a DBMS through 'sqlwbconsole' cannot be interrupted, there is
no reason to have 'sqlwbserver' working multi-threading. A new command will
have to wait anyway for the old one to finish.
C
Cosmin Popescu 已提交
163 164 165 166 167 168 169 170 171 172 173

If you want to have several connections to a database, you can open another
server (run again 'sqlwbserver') on another port. Of course, each server will
have it's own opened transactions. You cannot do an 'update' on a port and a
'rollback' on the other port.

Though, when you open a database explorer (which requires a profile), a new
instance of 'sqlwbconsole.sh' will be launched on a different thread. So any
commands for the database explorer will be run in parallel with any command
launched from any 'vim' buffer connected to the same port.

C
Cosmin Popescu 已提交
174
Example:
C
Cosmin Popescu 已提交
175
>
C
Cosmin Popescu 已提交
176
    'resources/sqlwbconsole -t /tmp -c /usr/bin/sqlwbconsole.sh -o 5000'
C
Cosmin Popescu 已提交
177
<
C
Cosmin Popescu 已提交
178 179 180 181 182 183 184 185

Note:

For  prior to build 118, please set the 'g:sw_use_old_sw'
variable to 1

------------------------------------------------------------------------------
CONNECTING A VIM BUFFER              *vim-sql-workbench-connecting_a_vim_buffer*
C
Cosmin Popescu 已提交
186 187 188 189 190 191

Once you have a server opened, you can connect any vim buffer to that server
using 'SWSqlConnectToServer' command. Once a buffer is connected to a server,
you can send any command from that buffer to the DBMS using the
'SWSqlExecuteCurrent', 'SWSqlExecuteSelected' or 'SWSqlExecuteAll' commands.

C
Cosmin Popescu 已提交
192 193
==============================================================================
THE DATABASE EXPLORER                  *vim-sql-workbench-the_database_explorer*
C
Cosmin Popescu 已提交
194 195 196

In order to open a database explorer, you need a profile.

C
Cosmin Popescu 已提交
197 198 199 200 201
You can create  profiles, either by using the
GUI, like
here (http://www.sql-workbench.net/manual/profiles.html#profile-intro),
either opening a sql buffer with 'SWSqlConnectToServer' and then executing
'WbStoreProfile'.
C
Cosmin Popescu 已提交
202 203 204 205

Once you have your profiles created, you can use 'SWDbExplorer' with the
desired profile as argument and you will connect to the database.

C
Cosmin Popescu 已提交
206 207
For example,  will open a database explorer
using the profile 'myProfile' and the server which listens on the 5000 port.
C
Cosmin Popescu 已提交
208

C
Cosmin Popescu 已提交
209 210 211 212 213
The database explorer is composed from three parts: on the top, there is a
list of available shortcuts at any moment. On the bottom left, you will see
the list of objects in your database (the list of tables and views or the list
of procedures or the list of triggers etc.) and on the bottom right, you will
see the selected object desired properties. Like in the second or third screen
C
Cosmin Popescu 已提交
214 215
shot.

C
Cosmin Popescu 已提交
216 217 218 219 220
So, if you want to see the columns of a table, you will have to move the
cursor in the bottom left panel, go to the desired table and press 'C'. This
will display in the right panel the table columns, indices and triggers. If
you want to see its source code, you press 'S' and so on. For all the
available shortcuts, see the top panel.
C
Cosmin Popescu 已提交
221 222 223 224

The database explorer if fully customizable. You can use the existing one and
extend it or you can create your own from scratch.

C
Cosmin Popescu 已提交
225 226
------------------------------------------------------------------------------
CREATING A NEW DATABASE EXPLORER FROM SCRATCH *vim-sql-workbench-creating_a_new_database_explorer_from_scratch*
C
Cosmin Popescu 已提交
227 228 229 230 231 232 233 234

The database explorer is loaded from the 'resources/dbexplorer.vim' file by
default. If you want to write your own, set the 'g:sw_dbexplorer_panel'
variable to point to your own file and that file will be loaded. The file has
to be a 'vimscript' file, since it's going to be sourced and it needs to set
the 'g:SW_Tabs' variable. For an example, take a look at the
'resources/dbexplorer.vim' file.

C
Cosmin Popescu 已提交
235 236 237
The 'g:SW_Tabs' has to be a vim dictionary. The keys are the profiles for
which the panel will be applied. '*' profile, means that the options appear on
all profiles. If you want to have separate database explorers for separate
C
Cosmin Popescu 已提交
238 239
profiles, you can create a key in the dictionary for each explorer.

C
Cosmin Popescu 已提交
240 241 242 243 244 245 246 247 248 249 250 251 252
You can also have profiles per type of DBMS. If you have a profile starting
with a ':' or a '^'.

A ':' means that this options will appear for all the profiles which the DBMS
is of that type. For example ':MySQL' it means that these options will appear
only for 'mysql' databases.

A '^' means that this options will appear for all the profiles for which the
DBMS is not of that type. For example '^PostgreSQL' means that there options
will appear for all databases which are not 'PostgreSQL'.

For this to work, you have to have the option 'g:sw_config_dir' set. The
profile informations are read from the 'WbProfiles.xml' file which resides in
C
Cosmin Popescu 已提交
253
this folder. The profile type you can see it in the
C
Cosmin Popescu 已提交
254 255 256 257 258 259 260 261 262 263 264
connection window. It's the driver title.

Starting with version '4.0' you can also have a vimscript function called
instead of a sql query. The function called has to return a string which will
be interpreted as the result of the operation. The function will receive as
parameters the line selected (the complete line which has been selected). In
order to have a function instead of a sql query in the database explorer, the
'command' has to begin with ':'.

For example:
>
C
Cosmin Popescu 已提交
265
    {'title': 'Data', 'shortcut': 'D', 'command': ':My_function'}
C
Cosmin Popescu 已提交
266
<
C
Cosmin Popescu 已提交
267

C
Cosmin Popescu 已提交
268
When the shortcut D will be pressed, the result will be fetch by calling
C
Cosmin Popescu 已提交
269
'My_function(getline('.'))'
C
Cosmin Popescu 已提交
270

C
Cosmin Popescu 已提交
271 272
Of course, the current line is only relevant only for when changing a tab.
When changing a tab, the current line will contain whatever value is on the
C
Cosmin Popescu 已提交
273
currently line in whatever buffer you are at that moment.
C
Cosmin Popescu 已提交
274 275 276 277 278 279 280 281

The values for each profile, have to be a list which will contain all the
options for the left panel. For example, in the default one, the database
objects, triggers and procedures.

Each list of objects of this list is another dictionary, with the following
keys:

C
Cosmin Popescu 已提交
282 283 284 285 286 287
*   'title' (the title which will be displayed in the top panel)
*   'shortcut' (the shortcut to access it; please note that you can have several
    letters)
*   'command' (the sql command which will be executed when selecting the object)
*   'panels' (a list of options accessible in the right panel for each selected
    object in the left panel)
C
Cosmin Popescu 已提交
288 289 290 291

The panels are also a list of dictionaries. Each element of the list has the
following keys:

C
Cosmin Popescu 已提交
292 293 294 295 296
*   'title' (the title which will be displayed in the top panel)
*   'shortcut' (the shortcut which will be used to display it)
*   'command' (the sql command which will be executed; please note that the sql
    command should contain the '%object%' string, which will be replaced with
    the name of the selected object)
C
Cosmin Popescu 已提交
297 298 299

Optional, the panels might contain the following keys:

C
Cosmin Popescu 已提交
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
*   'skip_columns' (a list with the column indices from the result set that
    should not be displayed)
*   'hide_header' (if set and 'true', then the header of the result set will not
    be displayed in the bottom right panel)
*   'filetype' (if present, the bottom right panel 'filetype' will be set
    according when selecting an object in the left panel)

NOTES:

1.  In the command that creates the left panel, the object for which you want
    to select the informations in the right panel should always be on the first
    column. The '%object%' string in the column will be replaced by it.
    Alternatively, you can have '%n%' (n being a number from 0 to the number of
    columns in the left panel). If you have '%n%', this will be replaced by the
    value of that column
2.  The command can contain a comment in the format  at the end.
    Everything following "AFTER" word will be interpreted as a VIM command and
    will be executed after the result has been displayed in the right panel. For
    an example, see the SQL Source panel in the default database explorer vim
    file ('resources/dbexplorer.vim').
3.  The shortcuts for the left panel (the list of objects) have to be unique.
    They are used to identify the current option selected to be displayed, so
    that the shourtcuts for the left panel are loaded according to the panels.
    However, the shortcuts for the right panel can be the same from one list of
    objects to the other. For example, you can have "O" as shortcut for objects
    list and then for each object you can have "S" for showing the source code.
    Then, you can have "P" for listing the procedures. Again, for each procedure
    you can have again "S" as shortcut for listing the source code of a
    procedure or for something else.

------------------------------------------------------------------------------
EXTENDING THE DEFAULT DATABASE EXPLORER *vim-sql-workbench-extending_the_default_database_explorer*
C
Cosmin Popescu 已提交
332 333

If you are happy with the default options of the database explorer (which are
C
Cosmin Popescu 已提交
334 335
the same with the ones of ) but you just want to add your
own, you can do so by extending the default database explorer.
C
Cosmin Popescu 已提交
336 337 338 339

This is done by calling the 'vimscript' function 'sw#dbexplorer#add_tab'. The
function takes the following arguments:

C
Cosmin Popescu 已提交
340 341 342 343 344 345 346 347
*   The profile (the profile for which the option should be active; it can be
    '*' for all profiles)
*   The title (this is the title that will appear on the top panel)
*   The shortcut (this is the shortcut to access it)
*   The command (this is the SQL command to be sent to the DBMS once this option
    is selected)
*   The list of panels (the list of properties to be displayed in the bottom
    right split for each object from the list)
C
Cosmin Popescu 已提交
348 349 350 351 352 353

The list of panels is an array of dictionaries. Each dictionary has the same
keys as indicated in the previous section for the list of panels. For example,
if you want to add the database links for all the profiles, you have to add
this in your 'vimrc':
>
C
Cosmin Popescu 已提交
354 355 356
    call sw#dbexplorer#add_tab('*', 'DB Links', 'L', 'select db_link, username,
    created  from user_db_links;', [{'title': 'Show the host', 'shortcut': 'H',
    'command': "select host from user_db_links where db_link = '%object%'"}])
C
Cosmin Popescu 已提交
357
<
C
Cosmin Popescu 已提交
358

C
Cosmin Popescu 已提交
359 360
Now on all profiles, you will have an extra option. Every time when you click
"L" in normal mode, in the bottom left panel you will have a list of database
C
Cosmin Popescu 已提交
361 362 363 364 365 366 367 368 369 370 371 372 373
links from your schema. For each link, you can move the cursor on top of it
and click H. You will see in the right panel the source of the link.

Every time when "L" is clicked, 'vim-sqlworkbench' sends the  command to the DBMS. The result will be
a list of database links displayed in the bottom left panel.  When you move
your cursor on top of one of this links and press "H", the plugin sends to
your DBMS . The result is displayed in the right panel.

==============================================================================
THE SQL BUFFER                                *vim-sql-workbench-the_sql_buffer*

The SQL buffer is a normal 'vim' buffer from which you can send SQL commands
to your DBMS and in which you can use the omni completion (&lt;C-x&gt;&lt;C-o&gt;) to have
C
Cosmin Popescu 已提交
374 375 376
intellisense autocompletion.

You can connect an opened vim buffer to a server using the
C
Cosmin Popescu 已提交
377
 command. Or, you can open a buffer which will be
C
Cosmin Popescu 已提交
378
directly connected to a server by specifying the path to the buffer after the
C
Cosmin Popescu 已提交
379
port. For example 
C
Cosmin Popescu 已提交
380 381 382 383

Once in an sql buffer, you have several ways to execute commands against your
DBMS:

C
Cosmin Popescu 已提交
384 385 386
*   execute the current SQL
*   execute the selected statement
*   execute all statements
C
Cosmin Popescu 已提交
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403

All the shortcuts for these commands are fully customizable. But to do this,
you cannot just map the commands in 'vimrc'. This is because these shortcuts
are mapped local to the sql buffer, or to the result sets buffer. If you want
to change the default shortcuts, you need to define the
'g:sw_shortcuts_sql_buffer_statement' variable or the
'g:sw_shortcuts_sql_results' variable. This variables should point each to a
'vimscript' file which will define the mappings.

The 'g:sw_shortcuts_sql_buffer_statement' variable is used for the sql buffer
itself, while the 'g:sw_shortcuts_sql_results' variable is used for the result
set buffer (see the 4th scren shot).

As soon as a SQL buffer is opened the shortcuts from the
'g:sw_shortcuts_sql_buffer_statement' will be mapped. If the variable is not
set, then the 'resources/shortcuts_sql_buffer_statement.vim' file is loaded.
So, have a look at this file for further details. Please note that for
C
Cosmin Popescu 已提交
404
executing the current SQL, the default shortcut is .
C
Cosmin Popescu 已提交
405 406 407 408 409 410

The same goes for a result set buffer. The shortcuts from the file pointed by
the 'g:sw_shortcuts_sql_results' variable are loaded. If the variable is not
set, then the shortcuts from 'resources/shortcuts_sql_results.vim' are loaded.
If you want further details, please have a look at this file.

C
Cosmin Popescu 已提交
411 412 413 414
You can also have comment in the format  on a single
line. This comments will be parsed by the plugin. If the command begins with a
':' it will be interpreted as a 'vim' command and executed by vim. Otherwise,
the command will be sent to the DBMS when opening the file.
C
Cosmin Popescu 已提交
415 416 417

Examples:

C
Cosmin Popescu 已提交
418

C
Cosmin Popescu 已提交
419 420

This command will load the intellisense autocomplete options saved in with
C
Cosmin Popescu 已提交
421 422
.

C
Cosmin Popescu 已提交
423 424 425 426 427


This command will be sent to the DBMS and will start a new transaction every
time when you open this buffer.

C
Cosmin Popescu 已提交
428 429
------------------------------------------------------------------------------
EXECUTE THE CURRENT STATEMENT  *vim-sql-workbench-execute_the_current_statement*
C
Cosmin Popescu 已提交
430

C
Cosmin Popescu 已提交
431 432
As stated already, you can press  in normal or insert mode or
you can have your own shortcut. Alternatively, in normal mode, you can execute
C
Cosmin Popescu 已提交
433 434
'SWSqlExecuteCurrent' command.

C
Cosmin Popescu 已提交
435 436 437
The statement between the last 2 delimiters will be sent to the server, or
from the beginning of the file until the first delimiter, or from the last
delimiter to the end of the file, depending on where your cursor is placed.
C
Cosmin Popescu 已提交
438 439 440 441 442

By default, if you execute 'SWSqlExecuteCurrent', vim will wait for the result
before continuing. If you don't want to wait for the result, you can execute
'SWSqlExecuteCurrent!'.

C
Cosmin Popescu 已提交
443 444
Note: The default shortcut is mapped using 'SWSqlExecuteCurrent!', which
means that pressing  will execute the current command asynchronous.
C
Cosmin Popescu 已提交
445

C
Cosmin Popescu 已提交
446 447
------------------------------------------------------------------------------
EXECUTE THE SELECTED STATEMENT *vim-sql-workbench-execute_the_selected_statement*
C
Cosmin Popescu 已提交
448

C
Cosmin Popescu 已提交
449
In visual mode, you can press  or your own custom shortcut.
C
Cosmin Popescu 已提交
450
Alternatively, you can execute the 'SWSqlExecuteSelected' command. Please be
C
Cosmin Popescu 已提交
451 452
careful to delete the range before, if you want to execute the command from
the visual mode.
C
Cosmin Popescu 已提交
453 454 455

The selected text is going to be sent to the DBMS.

C
Cosmin Popescu 已提交
456 457 458
Like before, if you want the command executed asynchronous, you have to use
the exclamation mark after it ('SWSqlExecuteSelected!'). By default, this is
mapped on . You can change this mapping.
C
Cosmin Popescu 已提交
459

C
Cosmin Popescu 已提交
460 461
------------------------------------------------------------------------------
EXECUTE ALL STATEMENTS                *vim-sql-workbench-execute_all_statements*
C
Cosmin Popescu 已提交
462

C
Cosmin Popescu 已提交
463 464 465
In visual mode, you can press  or your own custom shortcut.
Alternatively, you can execute the 'SWSqlExecuteAll' command. All the buffer
is going to be sent to the DBMS.
C
Cosmin Popescu 已提交
466 467 468 469

Also here you can use an exclamation mark to execute the command asynchronous,
which is the default mapping.

C
Cosmin Popescu 已提交
470 471
------------------------------------------------------------------------------
PROFILING                                          *vim-sql-workbench-profiling*
C
Cosmin Popescu 已提交
472

C
Cosmin Popescu 已提交
473
Unfortunately, the  console application does not return the
C
Cosmin Popescu 已提交
474 475 476 477
time that it took for a command to execute. This plugin will try to do some
profiling, but it will report the full time it took for a command to execute.
This means that this time will also include the communication with the
'sqwbconsole' server, the time to display the results in console (if on debug
C
Cosmin Popescu 已提交
478
mode) the time it took  console application to communicate
C
Cosmin Popescu 已提交
479 480
with the DBMS via 'jdbc' and any other operations involved.

C
Cosmin Popescu 已提交
481
So, if you want to do some profiling, try to either to  (this would eliminate some operations, like displaying the results
C
Cosmin Popescu 已提交
482 483 484
in console if in debug mode) or to set the maximum number of results to a low
value (like 10). And (of course), send only one query at a time.

C
Cosmin Popescu 已提交
485 486
------------------------------------------------------------------------------
INTELLISENSE                                    *vim-sql-workbench-intellisense*
C
Cosmin Popescu 已提交
487 488

'vim-sqlworkbench' plugin comes with intellisense out of the box. In order to
C
Cosmin Popescu 已提交
489 490 491 492 493
take advantage of the auto complete intellisense, you have to execute first
the 'SWSqlAutocomplete' command. Depending on how many tables and views you
have in your database, it might take even more than one minute. After the
command is executed, normally you can press &lt;C-x&gt;&lt;C-u&gt; in insert
mode in a sql statement.
C
Cosmin Popescu 已提交
494

C
Cosmin Popescu 已提交
495
Note: due to constant conflicts with dbext plugin (which apparently has some
C
Cosmin Popescu 已提交
496
parts included in the '/usr/share/vim' folder) I prefer to switch to
C
Cosmin Popescu 已提交
497 498
&lt;C-x&gt;&lt;C-u&gt;. So, you cannot use &lt;C-x&gt;&lt;C-u&gt; anymore for
intellisense
C
Cosmin Popescu 已提交
499 500 501

The plugin will try to determine where you are in the sql and return the
appropriate options. For example, if you are in the fields part of a 'select'
C
Cosmin Popescu 已提交
502 503 504 505 506
statement, the options returned will be the fields based on the tables from
the 'from' part of the 'select'. If you are in the 'from' part, then the list
of tables is returned. If you have an identifier followed by a dot, then if
that identifier is a table, a view or an alias of a view or subquery, the
system will return the corresponding list of fields.
C
Cosmin Popescu 已提交
507 508 509 510 511 512

Also the subqueries are parsed and the appropriate fields are returned.

If you are in a subquery in a bigger query, the auto complete will be executed
at the level of the subquery.

C
Cosmin Popescu 已提交
513 514
If you are in a 'union' 'select' statement, the system will try to determine
in which 'select' the cursor is placed and execute auto completion for that sql.
C
Cosmin Popescu 已提交
515

C
Cosmin Popescu 已提交
516 517 518 519 520 521
As stated before, enabling the auto completion for a buffer can take some
time. Normally, whenever you execute a 'SWSqlAutocomplete', the data is cached
in memory in vim buffer variables. If you want to persist in on the hard
drive with  command. This will save the
data on hard drive. Later you can reload it with . Combined with  comments in the file, you can have the
autocomplete loaded every time you open a file.
C
Cosmin Popescu 已提交
522

C
Cosmin Popescu 已提交
523 524 525 526 527
If you modify a table then, you can do .
This will be very fast, as it will only load the data for the table. You can
sent as many tables at once. Of course, more tables you send, the longer it
will take to complete. For example, you can do . This will reload the data for
'modified_table1' and 'modified_table2'.
C
Cosmin Popescu 已提交
528 529 530

If you drop a table, you can always execute 'SWSqlAutocomplete' with the name
of the table preceded by a '-'. This will eliminate the table from the
C
Cosmin Popescu 已提交
531
autocomplete list. For example: . You can
C
Cosmin Popescu 已提交
532
combine in the same statement adding and deleting of tables. For example:
C
Cosmin Popescu 已提交
533
.
C
Cosmin Popescu 已提交
534 535 536 537 538

You can also execute 'SWSqlAutocomplete!'. This will reset any autocomplete
option and will reload again all the tables.

Unfortunately, the autocomplete for the function and procedures is limited.
C
Cosmin Popescu 已提交
539 540 541 542
This is because  does not provide also a list of parameters
through a  command. I can only retrieve the name of the
function or procedure. Also, the autocomplete for the procedure and functions
is limited to the 'WbCall' command.
C
Cosmin Popescu 已提交
543

C
Cosmin Popescu 已提交
544
NOTE: The autocomplete feature is implemented using regular expressions.
C
Cosmin Popescu 已提交
545 546 547 548
Because of using regular expressions, it's possible that I've missed cases. If
you notice any case where the autocomplete is not working properly, please let
me know.

C
Cosmin Popescu 已提交
549 550
------------------------------------------------------------------------------
GET AN OBJECT DEFINITION            *vim-sql-workbench-get_an_object_definition*
C
Cosmin Popescu 已提交
551

C
Cosmin Popescu 已提交
552 553 554 555
When with the cursor on top of any word in the buffer or in the result set,
you can click  or your own custom shortcut. This will display that
object definition if the object exists in the result set buffer or an error
message.
C
Cosmin Popescu 已提交
556 557 558

Alternatively you can execute the 'SWSqlObjectInfo' command from normal mode.

C
Cosmin Popescu 已提交
559
Basically the command  is sent to the DBMS and the output
C
Cosmin Popescu 已提交
560 561
returned.

C
Cosmin Popescu 已提交
562
------------------------------------------------------------------------------
C
Cosmin Popescu 已提交
563
GET AN OBJECT SOURCE                    *vim-sql-workbench-get_an_object_source*
C
Cosmin Popescu 已提交
564 565

When you are with the cursor on top of any word in the buffer or in the result
C
Cosmin Popescu 已提交
566 567
set, you can click  or your own custom shortcut. This will display
the object source if the object exists in the result set buffer or an error
C
Cosmin Popescu 已提交
568 569 570 571 572
message.

Alternatively, you can execute the 'SWSqlObjectSource' command from normal
mode.

C
Cosmin Popescu 已提交
573 574
------------------------------------------------------------------------------
MAXIMUM NUMBER OF ROWS.              *vim-sql-workbench-maximum_number_of_rows.*
C
Cosmin Popescu 已提交
575

C
Cosmin Popescu 已提交
576 577 578
By default, the maximum number of results returned by a select is 5000. You
can change this with the  command. See
here (http://www.sql-workbench.net/manual/wb-commands.html#command-set)
C
Cosmin Popescu 已提交
579

C
Cosmin Popescu 已提交
580 581
------------------------------------------------------------------------------
CHANGING RESULT SETS DISPLAY MODE *vim-sql-workbench-changing_result_sets_display_mode*
C
Cosmin Popescu 已提交
582

C
Cosmin Popescu 已提交
583
In the result set buffer, you can click  or your own custom shortcut
C
Cosmin Popescu 已提交
584 585 586 587
on top of a row. This will toggle the row display to have each column on a row
for the selected row. To change back the display mode, click again the same
shortcut.

C
Cosmin Popescu 已提交
588 589
Alternatively, you can execute the 'WbDisplay' command. See
here (http://www.sql-workbench.net/manual/console-mode.html) for more detail.
C
Cosmin Popescu 已提交
590

C
Cosmin Popescu 已提交
591 592
==============================================================================
SQL COMMANDS                                    *vim-sql-workbench-sql_commands*
C
Cosmin Popescu 已提交
593 594 595 596 597 598 599 600 601 602 603

You can send a sql query to the DBMS from the vim command line using the
command 'SWSqlExecuteNow'. The first parameter is the port of the server on
which to execute, and the next parameters are the sql query. Please note that
by default no results will be shown. If you want to see all that happened on
the server side, use the 'SWSqlExecuteNowLastResult' command. This will show
you what happened with the last command sent from the vim command line.

This is useful if you want to put vim shortcuts for simple things. Like, for
example, you could have in your 'vimrc':
>
C
Cosmin Popescu 已提交
604
    nnoremap <leader>t :SWSqlExecuteNow 5000 wbdisplay tab;<cr>
C
Cosmin Popescu 已提交
605
<
C
Cosmin Popescu 已提交
606

C
Cosmin Popescu 已提交
607 608 609
Then pressing '<leader>t' in normal mode, would set the display to tab for the
instance listening on port 5000.

C
Cosmin Popescu 已提交
610
Note: This command will not be recorded in 'g:sw_last_sql_query'. The
C
Cosmin Popescu 已提交
611 612
delimiter is the ';'.

C
Cosmin Popescu 已提交
613 614
==============================================================================
SEARCHING                                          *vim-sql-workbench-searching*
C
Cosmin Popescu 已提交
615

C
Cosmin Popescu 已提交
616
 comes with two very handy and powerful commands:
C
Cosmin Popescu 已提交
617 618 619 620
'WbGrepSource' and 'WbGrepData'. 'vim-sqlworkbench' takes advantage of both of
them and implements searching options. You can search in objects source code,
or you can search tables data.

C
Cosmin Popescu 已提交
621 622
------------------------------------------------------------------------------
SEARCHING IN OBJECTS SOURCE CODE *vim-sql-workbench-searching_in_objects_source_code*
C
Cosmin Popescu 已提交
623 624

Of course, you can always execute 'WbGrepSource' in a sqlbuffer and send it to
C
Cosmin Popescu 已提交
625 626
the DBMS. For a full documentation of the command, please see
here (http://www.sql-workbench.net/manual/wb-commands.html#command-search-source).
C
Cosmin Popescu 已提交
627

C
Cosmin Popescu 已提交
628 629
Alternatively, you can call one of the three 'vim-sqlworkbench' search
commands available: 'SWSearchObject', 'SWSearchObjectAdvanced' or
C
Cosmin Popescu 已提交
630 631 632
'SWSearchObjectDefaults'.

The 'SWSearchObject' command will take one argument, which is the search
C
Cosmin Popescu 已提交
633
string. The command which will be sent to the DBMS is . This means that you execute a search with
C
Cosmin Popescu 已提交
634 635
default values. For a list of these, see the above link.

C
Cosmin Popescu 已提交
636
Example: 
C
Cosmin Popescu 已提交
637 638 639 640

The 'SWSearchObjectAdvanced' command will open an interactive command prompt
asking for every parameter value, beginning with the search terms.
Additionally, it will also require the columns to be displayed from the search
C
Cosmin Popescu 已提交
641 642 643 644 645 646 647 648 649 650
result. If you want to only search for some objects that contain a certain
term in their definition, you might not want to include the code of the
object. This might take multiple rows. In this case you will have to scroll in
the result buffer to see all the objects containing your term. If this is the
case, you can include only the "NAME" and "TYPE" columns.

If you leave the columns empty, then the plugin will return all the columns
but will remove all the rows from the source column. Only the first row from
each column will be displayed. If you want to see all the columns with all the
rows, you have to specify all the columns in the columns section
C
Cosmin Popescu 已提交
651 652 653 654 655 656 657
('NAME,TYPE,SOURCE'). Please note that you cannot change the order of the
columns.

The 'SWSearchObjectDefaults' command takes one argument (the search terms) and
will perform a search using all the defaults defined in 'vim-sqlworkbench'
plugin. These defaults can be changed in 'vimrc'.

C
Cosmin Popescu 已提交
658
Example: 
C
Cosmin Popescu 已提交
659

C
Cosmin Popescu 已提交
660 661
------------------------------------------------------------------------------
SEARCHING FOR DATA INSIDE TABLES *vim-sql-workbench-searching_for_data_inside_tables*
C
Cosmin Popescu 已提交
662 663

You can execute 'WbGrepData' in a sql buffer and send it to the DBMS. For a
C
Cosmin Popescu 已提交
664 665
full documentation of the command, please see
here (http://www.sql-workbench.net/manual/wb-commands.html#command-search-data).
C
Cosmin Popescu 已提交
666

C
Cosmin Popescu 已提交
667 668 669
Alternatively, you can call one of the three 'vim-sqlworkbench' search
commands available: 'SWSearchData', 'SWSearchDataAdvanced' or
'SWSearchDataDefaults'.
C
Cosmin Popescu 已提交
670 671 672 673 674 675 676 677

All the three commands work as their counter parts for searching object with
the exception that no column can be selected any more.

If you are in an sql buffer, then the results are displayed in the result sets
buffer. If you are in a database explorer, then the search results are
displayed in the bottom right panel.

C
Cosmin Popescu 已提交
678 679
==============================================================================
EXPORTING                                          *vim-sql-workbench-exporting*
C
Cosmin Popescu 已提交
680

C
Cosmin Popescu 已提交
681
'vim-sqlworkbench' takes advantage of the very powerful
C
Cosmin Popescu 已提交
682 683
command, 'WbExport'.

C
Cosmin Popescu 已提交
684 685 686
As usual, you can always execute the 'WbExport' command inside a sql buffer.
To see the full documentation of the 'WbExport' command, have a look
here (http://www.sql-workbench.net/manual/command-export.html).
C
Cosmin Popescu 已提交
687

C
Cosmin Popescu 已提交
688
Note: If you use the wbexport command, you need to send both of the queries
C
Cosmin Popescu 已提交
689 690
at once, by selecting both queries (first the 'WbExport' query and then the
exported query) and then running 'SWSqlExecuteSelected'. This happens because
C
Cosmin Popescu 已提交
691 692
the plugin will send after each statement a silent command to notice vim that
a new result is waiting. So, if you execute 'WbExport', the exported statement
C
Cosmin Popescu 已提交
693 694 695 696 697 698 699 700 701
will be the silent one which is void and is not a 'select' statement.

Or you can execute the 'SWSqlExport' command. This will open an interactive
input dialog which will ask for the format and the destination file and will
export the last sql command. If you are in a database explorer, in the right
panel, you can click on "E". This shortcut is not modifiable. This will export
what ever is in the right panel, after asking for the format and the
destination file. Please note that because of extra dependencies required for
'xls' export, 'vim-sqlworkbench' does not provide support for this format.
C
Cosmin Popescu 已提交
702 703 704
However, you can export as 'ods', which is what you should use anyway. See
here (http://www.fsf.org/campaigns/opendocument/) or
here (http://www.fsf.org/campaigns/opendocument/download)
C
Cosmin Popescu 已提交
705

C
Cosmin Popescu 已提交
706 707
==============================================================================
SESSIONS                                            *vim-sql-workbench-sessions*
C
Cosmin Popescu 已提交
708 709

'vim-sqlworkbench' provides support for vim sessions. You have to have the
C
Cosmin Popescu 已提交
710
'globals' enabled in your session options ().
C
Cosmin Popescu 已提交
711

C
Cosmin Popescu 已提交
712 713 714 715
However, the session restore is done in two steps. As soon as you restore a
vim session, you will notice that for example a database explorer is empty and
pressing the shortcuts will have no effect. You have, when entering in the
tab, to call the command 'SWDbExplorerRestore'.
C
Cosmin Popescu 已提交
716 717 718 719 720 721

Similar, when entering an sql buffer after a session restore, you will notice
that executing statements against the DBMS will produce vim errors. Before
executing any statement, you have to call the 'SWSqlBufferRestore'. This will
also restore the autocomplete list, so you will also have the autocomplete.

C
Cosmin Popescu 已提交
722 723
==============================================================================
VARIABLES                                          *vim-sql-workbench-variables*
C
Cosmin Popescu 已提交
724

C
Cosmin Popescu 已提交
725 726 727
 supports user defined variables (you can have your queries
sent to the database parameterized). See
here (http://www.sql-workbench.net/manual/using-variables.html).
C
Cosmin Popescu 已提交
728 729 730 731

This plugin takes advantage of that and implements a few commands to help you
use variables.

C
Cosmin Popescu 已提交
732 733 734
By default, in , the variables are enclosed between '$[' and
']'. These can be
changed (http://www.sql-workbench.net/manual/using-variables.html#access-variable).
C
Cosmin Popescu 已提交
735

C
Cosmin Popescu 已提交
736 737 738 739
You can use 'WbVarSet' and 'WbVarUnset' in a sql buffer. If you want the
system to ask for a value, then you can use the '$[?' form of a parameter.
Please note that in  there is no difference between '?' and
'&', since there is no way to get a list of vars in 'vimscript' from 
C
Cosmin Popescu 已提交
740

C
Cosmin Popescu 已提交
741 742
==============================================================================
COMMANDS                                            *vim-sql-workbench-commands*
C
Cosmin Popescu 已提交
743

C
Cosmin Popescu 已提交
744 745
------------------------------------------------------------------------------
SWDBEXPLORER                                    *vim-sql-workbench-swdbexplorer*
C
Cosmin Popescu 已提交
746

C
Cosmin Popescu 已提交
747
Parameters:
C
Cosmin Popescu 已提交
748

C
Cosmin Popescu 已提交
749 750
*   profile name: the name of the profile for which to open the database explorer.
*   port: the port on which the server listens
C
Cosmin Popescu 已提交
751 752 753 754

Opens a database explorer for the desired profile using the server from the
specified port.

C
Cosmin Popescu 已提交
755 756 757 758
NOTE: If you set the
'g:sw_config_dir' variable to point to the  settings folder,
the command will autocomplete the profile names. See
here (http://www.sql-workbench.net/manual/install.html#config-dir)
C
Cosmin Popescu 已提交
759

C
Cosmin Popescu 已提交
760 761
------------------------------------------------------------------------------
SWDBEXPLORERCLOSE                          *vim-sql-workbench-swdbexplorerclose*
C
Cosmin Popescu 已提交
762

C
Cosmin Popescu 已提交
763
Parameters;
C
Cosmin Popescu 已提交
764

C
Cosmin Popescu 已提交
765 766
*   profile name (optional): the name of the database explorer that should be
    closed.
C
Cosmin Popescu 已提交
767 768 769 770 771 772 773 774

Closes a database explorer. If no profile name is specified, if you are inside
a database explorer, then that database explorer is closed. Otherwise, the
system will generate an error.

If you specify a profile name, then the database explorer which is opened for
the indicated profile is closed.

C
Cosmin Popescu 已提交
775 776
------------------------------------------------------------------------------
SWDBEXPLORERRESTORE                      *vim-sql-workbench-swdbexplorerrestore*
C
Cosmin Popescu 已提交
777 778 779

After a session restore, this command will restore an opened database panel

C
Cosmin Popescu 已提交
780 781
------------------------------------------------------------------------------
SWSQLEXECUTECURRENT                      *vim-sql-workbench-swsqlexecutecurrent*
C
Cosmin Popescu 已提交
782 783 784 785 786 787 788

In an sql buffer executes the current statement. You can execute this command
in normal or insert mode. This is the statement between two consecutive
identifiers, or from the beginning of the file to the first identifier or from
the last identifier to the end of the file. You can change the delimiter using
the 'SWSqlDelimiter' command.

C
Cosmin Popescu 已提交
789 790
------------------------------------------------------------------------------
SWSQLEXECUTESELECTED                    *vim-sql-workbench-swsqlexecuteselected*
C
Cosmin Popescu 已提交
791

C
Cosmin Popescu 已提交
792 793
In an sql buffer, executes the current selected statement. The command works
in visual mode. Be careful to delete the range before typing the command.
C
Cosmin Popescu 已提交
794

C
Cosmin Popescu 已提交
795 796
------------------------------------------------------------------------------
SWSQLEXECUTEALL                              *vim-sql-workbench-swsqlexecuteall*
C
Cosmin Popescu 已提交
797 798 799

Send all sql statements from the buffer to the DBMS.

C
Cosmin Popescu 已提交
800 801
------------------------------------------------------------------------------
SWSQLTOGGLEMESSAGES                      *vim-sql-workbench-swsqltogglemessages*
C
Cosmin Popescu 已提交
802 803

If you have a result set displayed in the result set buffer, you can toggle
C
Cosmin Popescu 已提交
804 805 806
between the result displayed and the messages produced by the command with
this command. The command works from the sql buffer and from the result set
buffer.
C
Cosmin Popescu 已提交
807

C
Cosmin Popescu 已提交
808 809
------------------------------------------------------------------------------
SWSQLOBJECTINFO                              *vim-sql-workbench-swsqlobjectinfo*
C
Cosmin Popescu 已提交
810 811

In a sql buffer or in a result set buffer, you can position the cursor on top
C
Cosmin Popescu 已提交
812 813
of any word and call this command. The plugin will send to the DBMS . If the word that you selected is a valid database object, you will
see its definition. Otherwise it will return an error.
C
Cosmin Popescu 已提交
814

C
Cosmin Popescu 已提交
815 816
------------------------------------------------------------------------------
SWSQLOBJECTSOURCE                          *vim-sql-workbench-swsqlobjectsource*
C
Cosmin Popescu 已提交
817 818 819 820 821 822

Like the previous command, if you are with your cursor on top of a word and
call this command, the plugin will return it's source code, if the selected
word is an object in the database. Otherwise, it will return an empty result
set.

C
Cosmin Popescu 已提交
823 824
------------------------------------------------------------------------------
SWSQLEXECUTENOW                              *vim-sql-workbench-swsqlexecutenow*
C
Cosmin Popescu 已提交
825

C
Cosmin Popescu 已提交
826
Parameters:
C
Cosmin Popescu 已提交
827

C
Cosmin Popescu 已提交
828 829
*   port: the port on which to execute the command
*   sql: The query to be sent to the DBMS
C
Cosmin Popescu 已提交
830 831 832

Executes a query against the DBMS on the indicated port.

C
Cosmin Popescu 已提交
833 834
------------------------------------------------------------------------------
SWSQLEXECUTENOWLASTRESULT          *vim-sql-workbench-swsqlexecutenowlastresult*
C
Cosmin Popescu 已提交
835 836 837

Shows the communication with the server for the last 'SWSqlExecuteNow' command.

C
Cosmin Popescu 已提交
838 839
------------------------------------------------------------------------------
SWSQLEXPORT                                      *vim-sql-workbench-swsqlexport*
C
Cosmin Popescu 已提交
840 841

This command will export the last executed statement. Of course, if your last
C
Cosmin Popescu 已提交
842 843 844 845
statement did not produced any results, you will have an empty file. The
plugin will ask you about the format and about the output file. You can export
in one of the following formats: 'text', 'sqlinsert', 'sqlupdate',
'sqldeleteinsert', 'xml', 'ods', 'html', 'json'.
C
Cosmin Popescu 已提交
846

C
Cosmin Popescu 已提交
847 848
------------------------------------------------------------------------------
SWSEARCHOBJECT                                *vim-sql-workbench-swsearchobject*
C
Cosmin Popescu 已提交
849

C
Cosmin Popescu 已提交
850
Parameters:
C
Cosmin Popescu 已提交
851

C
Cosmin Popescu 已提交
852
*   search terms: the terms that you are searching.
C
Cosmin Popescu 已提交
853 854

This command performs a search in the source code of the database objects. It
C
Cosmin Popescu 已提交
855 856 857 858
uses the defaults of . The command which is used is
'WbGrepSource'. You can see more details about the parameters and their
default values
here (http://www.sql-workbench.net/manual/wb-commands.html#command-search-source).
C
Cosmin Popescu 已提交
859 860 861 862 863

The search result will only return the first row of each column. This means
that you will have to select each term that you want to inspect and see it's
source using the 'SWSqlObjectSource' command. If you want to see the full
output you have to either set 'g:sw_search_default_result_columns' to
C
Cosmin Popescu 已提交
864 865 866
'NAME,TYPE,SOURCE' and execute the command 'SWSearchObjectDefaults', or you
can execute the 'SWSearchObjectAdvanced' command and select all three columns
when asked.
C
Cosmin Popescu 已提交
867

C
Cosmin Popescu 已提交
868 869
------------------------------------------------------------------------------
SWSEARCHOBJECTADVANCED                *vim-sql-workbench-swsearchobjectadvanced*
C
Cosmin Popescu 已提交
870 871 872 873 874 875 876

This command will perform an advanced search. It will ask for each possible
parameter. You can cancel the search at any time by replying with an empty
value. This, however, is not possible for the columns input, since the empty
string in the columns means that you want all the columns but only the first
row of each.

C
Cosmin Popescu 已提交
877 878
------------------------------------------------------------------------------
SWSEARCHOBJECTDEFAULTS                *vim-sql-workbench-swsearchobjectdefaults*
C
Cosmin Popescu 已提交
879

C
Cosmin Popescu 已提交
880
Parameters:
C
Cosmin Popescu 已提交
881

C
Cosmin Popescu 已提交
882
*   search terms: the terms that you are searching.
C
Cosmin Popescu 已提交
883 884 885 886

This command will perform a search using as default values for all the
parameters the values defined through the vim variables:

C
Cosmin Popescu 已提交
887 888 889 890 891
*   'g:sw_search_default_regex'
*   'g:sw_search_default_match_all'
*   'g:sw_search_default_ignore_case'
*   'g:sw_search_default_types'
*   'g:sw_search_default_compare_types'
C
Cosmin Popescu 已提交
892

C
Cosmin Popescu 已提交
893 894
------------------------------------------------------------------------------
SWSEARCHDATA                                    *vim-sql-workbench-swsearchdata*
C
Cosmin Popescu 已提交
895

C
Cosmin Popescu 已提交
896
Parameters:
C
Cosmin Popescu 已提交
897

C
Cosmin Popescu 已提交
898
*   search terms: the terms that you are searching.
C
Cosmin Popescu 已提交
899 900

This command performs a search in the data in the tables. It uses the defaults
C
Cosmin Popescu 已提交
901 902 903
of . The command which is used is 'WbGrepData'. You can see
more details about the parameters and their default values
here (http://www.sql-workbench.net/manual/wb-commands.html#command-search-data).
C
Cosmin Popescu 已提交
904

C
Cosmin Popescu 已提交
905 906
------------------------------------------------------------------------------
SWSEARCHDATAADVANCED                    *vim-sql-workbench-swsearchdataadvanced*
C
Cosmin Popescu 已提交
907 908 909

This command will perform an advanced search in the tables data. It will ask
for each possible parameter. You can cancel the search at any time by replying
C
Cosmin Popescu 已提交
910 911 912
with an empty value, with the exception of the 'excludeTables' parameter,
since an empty value here means that you want to search in all the tables and
is not an unusual request.
C
Cosmin Popescu 已提交
913

C
Cosmin Popescu 已提交
914 915
------------------------------------------------------------------------------
SWSEARCHDATADEFAULTS                    *vim-sql-workbench-swsearchdatadefaults*
C
Cosmin Popescu 已提交
916

C
Cosmin Popescu 已提交
917
Parameters:
C
Cosmin Popescu 已提交
918

C
Cosmin Popescu 已提交
919
*   search terms: the terms that you are searching.
C
Cosmin Popescu 已提交
920 921 922 923

This command will perform a search in tables data using as default values for
all the parameters the values defined through the vim variables:

C
Cosmin Popescu 已提交
924 925 926 927 928 929
*   'g:sw_search_default_ignore_case'
*   'g:sw_search_default_compare_types'
*   'g:sw_search_default_tables'
*   'g:sw_search_default_data_types'
*   'g:sw_search_default_exclude_tables'
*   'g:sw_search_default_exclude_lobs'
C
Cosmin Popescu 已提交
930

C
Cosmin Popescu 已提交
931 932
------------------------------------------------------------------------------
SWSQLAUTOCOMPLETE                          *vim-sql-workbench-swsqlautocomplete*
C
Cosmin Popescu 已提交
933 934

This command enables the intellisense autocomplete for the current sql buffer.
C
Cosmin Popescu 已提交
935
After this command you can use &lt;C-x&gt;&lt;C-o&gt; for autocomplete.
C
Cosmin Popescu 已提交
936 937

You can have as arguments any number of tables from the database to fetch the
C
Cosmin Popescu 已提交
938 939 940
autocomplete information only about those tables. You can also precede any
name table with a '-'. In this case, the information will be deleted from the
plugin cache.
C
Cosmin Popescu 已提交
941 942 943

The arguments are useful, if you use the 'g:sw_autocomplete_on_load' option.

C
Cosmin Popescu 已提交
944 945
------------------------------------------------------------------------------
SWSQLBUFFERRESTORE                        *vim-sql-workbench-swsqlbufferrestore*
C
Cosmin Popescu 已提交
946 947 948 949 950

This command will restore the properties of the sql buffer following a vim
session restore. This includes the autocomplete intellisense of the buffer, if
this was active when 'mksession' was executed.

C
Cosmin Popescu 已提交
951 952
------------------------------------------------------------------------------
SWSERVERSTART                                  *vim-sql-workbench-swserverstart*
C
Cosmin Popescu 已提交
953

C
Cosmin Popescu 已提交
954
Parameters:
C
Cosmin Popescu 已提交
955

C
Cosmin Popescu 已提交
956 957
*   the port: the port on which the server will listen
*   the profile: optional, you can choose a profile when starting the server
C
Cosmin Popescu 已提交
958

C
Cosmin Popescu 已提交
959
This command will spawn a new server which will launch a  in
C
Cosmin Popescu 已提交
960 961
console mode. This can be used if you want to use transactions.

C
Cosmin Popescu 已提交
962
Please note that you need  plugin in order to run this from
C
Cosmin Popescu 已提交
963 964
'vim'.

C
Cosmin Popescu 已提交
965 966
------------------------------------------------------------------------------
SWSERVERSTOP                                    *vim-sql-workbench-swserverstop*
C
Cosmin Popescu 已提交
967

C
Cosmin Popescu 已提交
968
Parameters:
C
Cosmin Popescu 已提交
969

C
Cosmin Popescu 已提交
970
*   the port: the port of the server to close.
C
Cosmin Popescu 已提交
971

C
Cosmin Popescu 已提交
972 973
This command will stop a server. Also the  instance in
console mode will be closed.
C
Cosmin Popescu 已提交
974

C
Cosmin Popescu 已提交
975 976
------------------------------------------------------------------------------
SWSQLCONNECTTOSERVER                    *vim-sql-workbench-swsqlconnecttoserver*
C
Cosmin Popescu 已提交
977

C
Cosmin Popescu 已提交
978
Parameters:
C
Cosmin Popescu 已提交
979

C
Cosmin Popescu 已提交
980 981
*   port: the port of the server
*   file name (optional): the name of the file to open.
C
Cosmin Popescu 已提交
982 983 984 985 986

This will open a new buffer which will be connected to an existing
'sqlwbconsole' server. If the file name is not specified, then it will connect
the current buffer to the server on the specified port.

C
Cosmin Popescu 已提交
987 988
------------------------------------------------------------------------------
SWDBEXPLORERRECONNECT                  *vim-sql-workbench-swdbexplorerreconnect*
C
Cosmin Popescu 已提交
989

C
Cosmin Popescu 已提交
990 991 992
Reconnects the database explorer. This is useful if a timeout has occured
while having a database connection opened. Then you call the
'SWDbExplorerReconnect' in order to be able to execute commands again.
C
Cosmin Popescu 已提交
993

C
Cosmin Popescu 已提交
994 995
==============================================================================
SETTINGS                                            *vim-sql-workbench-settings*
C
Cosmin Popescu 已提交
996

C
Cosmin Popescu 已提交
997 998
------------------------------------------------------------------------------
SEARCH OBJECT SOURCE SETTINGS: *vim-sql-workbench-search_object_source_settings:*
C
Cosmin Popescu 已提交
999

C
Cosmin Popescu 已提交
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
*   'g:sw_search_default_result_columns': the default list of columns to be
    included in a search result; default value: ""
*   'g:sw_search_default_regex': whether to use regular expressions or not when
    performing a search; default value: "Y"
*   'g:sw_search_default_match_all': whether to match or not all the search
    terms or only one (use 'OR' or 'AND' when performing the search); default
    value: "Y"
*   'g:sw_search_default_ignore_case': whether to ignore the case or not when
    performing a search; default value: "Y"
*   'g:sw_search_default_types': the types of object in which to search; default
    value: "LOCAL TEMPORARY,TABLE,VIEW,FUNCTION,PROCEDURE,TRIGGER,SYNONYM"
C
Cosmin Popescu 已提交
1011

C
Cosmin Popescu 已提交
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035
Note: this values apply for the 'SWSearchObjectDefaults' command. The
'SWSearchObjectAdvanced' will ask for the value of each parameter and
'SWSearchObject' command will use the defaults of .

------------------------------------------------------------------------------
SEARCH DATA IN TABLES SETTINGS: *vim-sql-workbench-search_data_in_tables_settings:*

*   'g:sw_search_default_match_all': whether to match or not all the search
    terms or only one (use 'OR' or 'AND' when performing the search); default
    value: "Y"
*   'g:sw_search_default_compare_types': the type of search to be performed (the
    operator for the search); default value: "contains"
*   'g:sw_search_default_tables': the tables to be included in the search;
    default value: "%", which means all tables
*   'g:sw_search_default_data_types': the types of objects in which to perform
    the search; default value: "TABLE,VIEW"
*   'g:sw_search_default_exclude_tables': the list of tables to exclude from
    search; default value: ""
*   'g:sw_search_default_exclude_lobs': whether or not to exclude the 'blob' and
    'clob' columns from search; default value: "Y"

Note: this values apply for the 'SWSearchDataDefaults' command. The
'SWSearchDataAdvanced' will ask for the value of each parameter and
'SWSearchData' command will use the defaults of .
C
Cosmin Popescu 已提交
1036

C
Cosmin Popescu 已提交
1037 1038 1039 1040
To see more about these parameters, see
here (http://www.sql-workbench.net/manual/wb-commands.html#command-search-source)
and
here (http://www.sql-workbench.net/manual/wb-commands.html#command-search-data)
C
Cosmin Popescu 已提交
1041

C
Cosmin Popescu 已提交
1042 1043
------------------------------------------------------------------------------
SQL BUFFER SETTINGS:                    *vim-sql-workbench-sql_buffer_settings:*
C
Cosmin Popescu 已提交
1044

C
Cosmin Popescu 已提交
1045 1046 1047 1048 1049 1050 1051 1052 1053
*   'g:sw_sqlopen_command': the vim command used by 'SWSqlConnectToServer'
    command to open a buffer; possible values: 'e|tabnew'; default value: "e",
    which means open with vim 'edit' command
*   'g:sw_tab_switches_between_bottom_panels': if set to true, then clicking tab
    in a db explorer will switch between the bottom panels
*   'g:sw_autocomplete_cache_dir': the location where the autocomplete
    information is saved. You'll need to set it on Windows to work.
*   'g:sw_switch_to_results_tab': If true, then switch to the results buffer
    after executting a query
C
Cosmin Popescu 已提交
1054

C
Cosmin Popescu 已提交
1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078
------------------------------------------------------------------------------
DATABASE EXPLORER SETTINGS        *vim-sql-workbench-database_explorer_settings*

*   'g:sw_default_right_panel_type': the file type of the bottom right panel
    when not specified; default value: "txt"

------------------------------------------------------------------------------
GENERAL SETTINGS:                          *vim-sql-workbench-general_settings:*

*   'g:sw_exe': the location of the  executable; default value:
    "sqlwbconsole.sh"
*   'g:sw_tmp': the location of your temporary folder; default value: "/tmp"
*   'g:sw_asynchronious': by default, the commands are executed synchronous; if
    you set this to 1, then the commands will be executed asynchronous
*   'g:sw_vim_exe': the default VIM executable location; this is used in
    conjunction with the asynchronous mode; default value: 'vim'
*   'g:sw_delete_tmp': if true, then delete the temporary files created to
    execute any command. Useful for debugging. You can set it to 0 and check all
    the generated files
*   'g:sw_use_old_sw': if true, then use an older version of
    (prior to build 118)

==============================================================================
SCREEN SHOTS                                    *vim-sql-workbench-screen_shots*
C
Cosmin Popescu 已提交
1079 1080 1081 1082 1083 1084 1085 1086