Vim Tips Wiki
(Manual import and fix of a tip that had an invalid title)
 
(Remove html character entities)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=156
 
|id=156
  +
|previous=155
|title=Describe a SQL table from Vim
 
  +
|next=158
|created=November 7, 2001 10:41
+
|created=November 7, 2001
 
|complexity=basic
 
|complexity=basic
 
|author=Demian L. Neidetcher
 
|author=Demian L. Neidetcher
 
|version=5.7
 
|version=5.7
 
|rating=17/10
 
|rating=17/10
  +
|category1=SQL
|text=
 
  +
|category2=
 
}}
 
}}
 
 
Here is a bash script to call from Vim, when you want information about a table while you are editing SQL code. Put the script in a file named describe.
 
Here is a bash script to call from Vim, when you want information about a table while you are editing SQL code. Put the script in a file named describe.
   
Line 17: Line 18:
   
 
f=aTempFile.sql
 
f=aTempFile.sql
u=<uName>
+
u=<uName>
p=&lt;pWord&gt;
+
p=<pWord>
d=&lt;dBase&gt;
+
d=<dBase>
   
 
echo "/* describe for $1"
 
echo "/* describe for $1"
echo "describe $1;" &gt; $f;
+
echo "describe $1;" > $f;
echo "quit;" &gt;&gt; $f;
+
echo "quit;" >> $f;
   
 
sqlplus -S $u/$p@$d @$f
 
sqlplus -S $u/$p@$d @$f
Line 32: Line 33:
 
Your path needs to include the script (as well as sqlplus), then from Vim you type:
 
Your path needs to include the script (as well as sqlplus), then from Vim you type:
   
:r !describe &lt;tableName&gt;
+
:r !describe <tableName>
   
 
That inserts a listing of the table columns, complete with Java/C comments.
 
That inserts a listing of the table columns, complete with Java/C comments.
   
== Comments ==
+
==Comments==
[[Category:SQL]]
 

Latest revision as of 08:34, 28 September 2008

Tip 156 Printable Monobook Previous Next

created November 7, 2001 · complexity basic · author Demian L. Neidetcher · version 5.7


Here is a bash script to call from Vim, when you want information about a table while you are editing SQL code. Put the script in a file named describe.

#!/usr/bin/bash

f=aTempFile.sql
u=<uName>
p=<pWord>
d=<dBase>

echo "/* describe for $1"
echo "describe $1;" > $f;
echo "quit;" >> $f;

sqlplus -S $u/$p@$d @$f
rm -f $f;
echo " end describe for $1 */"

Your path needs to include the script (as well as sqlplus), then from Vim you type:

:r !describe <tableName>

That inserts a listing of the table columns, complete with Java/C comments.

Comments[]