Vim for Oracle

197 views
Skip to first unread message

vicky b

unread,
Sep 24, 2012, 12:54:41 PM9/24/12
to vim...@googlegroups.com
HI All,

 I am  an enthusiastic vim fan but never used it much .I use sqldeveloper for db related tasks.Due you guys really feel comfortable in vim to write pl/sql and also can you guys also query the db and see the resutlset through vim.

--
Thanks & Regards
 Vickyb



Paul Stewart

unread,
Sep 24, 2012, 1:07:43 PM9/24/12
to vim...@googlegroups.com
Hi Vicky,

Yes to both questions. If you download the dbext script from the vim.org site you can access and view the data on any db. I use it in my day-to-day work...

The instructions are pretty straightforward on the script, so have a look and let me know if you have questions.

http://www.vim.org/scripts/script.php?script_id=356



Thanks
Paul Stewart
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Tim Chase

unread,
Sep 24, 2012, 1:17:15 PM9/24/12
to vim...@googlegroups.com, vicky b
On 09/24/12 11:54, vicky b wrote:
> I am an enthusiastic vim fan but never used it much .I use sqldeveloper
> for db related tasks.Due you guys really feel comfortable in vim to write
> pl/sql and also can you guys also query the db and see the resutlset
> through vim.

While I don't use it regularly for Oracle/pl/sql, I do use it for
T-SQL on SQL-Server for my day job. I don't use the dbext script
that Paul mentions, but I don't usually use *any* scripts, so don't
take it as a negative mark :-)

I usually just use vim for easy formatting, and the power of :g and
:s commands. I usually keep the master SQL in vim and copy into
Query Analyzer to test.

-tim




vicky b

unread,
Sep 24, 2012, 1:19:27 PM9/24/12
to Tim Chase, vim...@googlegroups.com
Thanks for the replies guys but in the present world where we leave with so much of ide and code completion and so many features what is that makes you guys stick to vim .. does it make your job simpler or features are great or your use to it.

Paul Stewart

unread,
Sep 24, 2012, 1:21:02 PM9/24/12
to vim...@googlegroups.com
Actually, I do that too, I should've mentioned...I think the thing that
I like about the dbext script is that I can do quick data validation
before I cut and paste into other functions etc (if I'm embedding in a
c# program or something similar)...I do like that with the script I can
do all my work however without the need for any other editor...
Paul

Paul Stewart

unread,
Sep 24, 2012, 1:22:02 PM9/24/12
to vim...@googlegroups.com
I should also mention that I use viemu on Visual Studio too....so I have
a variety of tools to meet my needs
www.viemu.com

Paul


On 09/24/2012 10:17 AM, Tim Chase wrote:

Paul Stewart

unread,
Sep 24, 2012, 1:30:16 PM9/24/12
to vim...@googlegroups.com
For me personally, number of reasons, but probably the main ones:

--it is so small
--it's fast
--it's totally customizable (you can pretty much set it up exactly as you need/want it)
--it works on pretty much every OS
--once you get used to it is it incredibly fast to use...it's so much quicker than if you have to use the mouse...it frees your mind to concentrate on the code, not the editor
--it's free!!

There are many many other reasons, these are just a few of my own ones.

Hope that helps...I would say give it a try....personally, I don't think you'll go back to another editor once you get proficient on vim

Tim Chase

unread,
Sep 24, 2012, 1:36:03 PM9/24/12
to vicky b, vim...@googlegroups.com
On 09/24/12 12:19, vicky b wrote:
> Thanks for the replies guys but in the present world where we
> leave with so much of ide and code completion and so many
> features what is that makes you guys stick to vim .. does it make
> your job simpler or features are great or your use to it.

First, I've used Vim for so long that I now find things like ":w"
appearing in my other editing tools (Query Analyzer, Word, etc), so
using Vim is habit.

Also, the power of Vim makes it very easy to perform quick
transformations on text/queries which I regularly do. For DB work,
one I frequently do is a

SELECT TOP 1 * FROM SomeTable

and run it in text-mode (rather than grid-mode). I then copy out
the headers in the results, paste them into Vim and issue a

:s/\t/,\r/g

to turn them into named columns that I can order as I see fit,
without hand-entering them all. That often makes the foundation of
a SELECT clause for me.

Matching parens/braces, syntax highlighting, batch transforms,
macros, etc. are all reasons I have trouble stepping away from Vim.

-tim




Paul Stewart

unread,
Sep 24, 2012, 1:45:54 PM9/24/12
to vim...@googlegroups.com
look at that...I learn something new today....

:s/\t/,\r/g

I didn't know that one...thanks

Tim Chase

unread,
Sep 24, 2012, 1:52:51 PM9/24/12
to vim...@googlegroups.com, Paul Stewart
On 09/24/12 12:45, Paul Stewart wrote:
> look at that...I learn something new today....
>
> :s/\t/,\r/g
>
> I didn't know that one...thanks

Granted, I'm lazy, so I've also been known to write SQL queries that
return SQL queries as the result-set, and then run those in turn. :-)

-tim


David Fishburn

unread,
Sep 24, 2012, 10:18:23 PM9/24/12
to vim...@googlegroups.com
On 24/09/2012 1:19 PM, vicky b wrote:
Thanks for the replies guys but in the present world where we leave with so much of ide and code completion and so many features what is that makes you guys stick to vim .. does it make your job simpler or features are great or your use to it.


I am the maintainer of dbext and a host of other related SQL support in Vim.

IDE features provided by other software are great and a number of them have been added to Vim via plugins.


SrchRplcHiGrp.vim : Search and/or replace based on a syntax highlight group

http://www.vim.org/scripts/script.php?script_id=848

Since I work with SQL all day, I primarily created it to UPPER CASE
keywords (SELECT, UPDATE, FROM, WHERE, ...) in SQL. But, it has nothing to do with SQL.

Basically, if Vim can colour highlight text in a file, then you can
choose to search and replace on those colour highlights. I justchoose sqlKeyword highlighting keywords and then to do a search and replace to transform those words into UPPER CASE strings.


There is also this plugin:
SQLUtilities : SQL utilities - Formatting, generate - columns lists,
procedures for databases
http://www.vim.org/scripts/script.php?script_id=492

The main purpose of this plugin is it will reformat SQL queries into a
nice readable format. But it has another option which will allow you
to UPPER CASE your keywords as well.


Tim, I noticed you mentioned you format SQL, have a look at the web page for this plugin it shows a few formatting examples.


dbext.vim : Provides database access to many dbms (Oracle, Sybase,
Microsoft, MySQL, DBI,..)
http://www.vim.org/scripts/script.php?script_id=356


This one was mentioned by Paul.  It can do far more than simply execute SQL.
One of the most useful features I find is the ability to execute SQL and prompt you for input parameters.  It can also do this for many different fileformats.  For example  assume you had the following Java code:

    String mySQL =
        "SELECT s.script, ts.event, t.name                  " +
        "     , s.script_language, sv.name                  " +
        "  FROM ml_script s, ml_table_script ts, ml_table t " +
            "     , ml_script_version sv                        " +
        " WHERE s.script_id   = " + script_version +
        "   AND ts.version    = "+obj.method() +
        "   AND ts.table_id   = t.table_id                  ";

 If you visually select from the "SELECT ... to the "; and ran
 :'<,'>DBExecSQL

 The Java filetype support would concatenate each individual string into
 one single string.  In this case it removed the " + " and concatenated
 the lines to result in the following (assuming this is on one line):
          SELECT s.script, ts.event, t.name , s.script_language, sv.name
           FROM ml_script s, ml_table_script ts, ml_table t
                  , ml_script_version sv
          WHERE s.script_id   = " + script_version + "
            AND ts.version    = "+obj.method() +"
            AND ts.table_id   = t.table_id

It will then prompt you for values for "script_version" and "obj.method()".
This allows you to execute the query and test it without having you to modify your code at all.

A number of different filetypes are supported, Java, Perl, PHP, VB, Vim, SQL.  More can be added.


Included with Vim 7.3 is the SQL Complete plugin.  It uses the OMNI completion built into Vim (CTRL-X CTRL-O) and will complete using SQL syntax keywords.

If you have the dbext plugin installed, it will also complete, tables, columns, stored procedures and other items.  It will dynamically pull these from whatever database you have it connect.  See the help file :h omni-sql-completion or :h ft_sql.txt



Tim, you also showed an example of how create a select column list by grabbing the headers (from a different program) and running a search and replace on it.

SQLComplete.vim has provisions for doing just that.  When on a table name, a key stroke will replace the table name with a comma separated list of columns from that table.


Anyway, there is a bunch more to the SQL support I have added in Vim, but that should give people a fairly good overview.

David.


Paul Stewart

unread,
Sep 25, 2012, 1:08:56 AM9/25/12
to vim...@googlegroups.com
Hi David,

Thanks for the info, I only use about 20% of the power of your plugins I'm sure.
Thanks for maintaining them, they are a great help.

Paul Stewart

talek

unread,
Sep 27, 2012, 6:42:36 AM9/27/12
to vim...@googlegroups.com
Hi,

You may also have a look on VoraX: https://github.com/talek/vorax

vicky b

unread,
Oct 4, 2012, 2:40:39 AM10/4/12
to vim...@googlegroups.com
do we have anything for mysql 

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Paul Stewart

unread,
Oct 4, 2012, 10:28:45 AM10/4/12
to vim...@googlegroups.com
Hi Vicky,

DBext also can be connected to MySql

Paul

David Fishburn

unread,
Oct 4, 2012, 1:21:59 PM10/4/12
to vim...@googlegroups.com, vim...@googlegroups.com
Yes everything I outlined in my email is for all databases supported by the dbext plugin. That is around 14 databases plus ODBC and Perl's DBI interface. 

--
David Fishburn

Reply all
Reply to author
Forward
0 new messages