annotate runtime/doc/ft_sql.txt @ 27303:9e0ac05f579a v8.2.4180

patch 8.2.4180: 'balloonexpr' is evaluated in the current script context Commit: https://github.com/vim/vim/commit/5600a709f453045c80f92087acc0f855b4af377a Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 22 15:09:36 2022 +0000 patch 8.2.4180: 'balloonexpr' is evaluated in the current script context Problem: 'balloonexpr' is evaluated in the current script context. Solution: Use the script context where the option was set.
author Bram Moolenaar <Bram@vim.org>
date Sat, 22 Jan 2022 16:15:02 +0100
parents e69e7133c9cf
children d19b7aee1925
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18879
af69c9335223 Vim 8.2 release
Bram Moolenaar <Bram@vim.org>
parents: 18831
diff changeset
1 *ft_sql.txt* For Vim version 8.2. Last change: 2019 Dec 07
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
2
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
3 by David Fishburn
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
4
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
5 This is a filetype plugin to work with SQL files.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
6
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
7 The Structured Query Language (SQL) is a standard which specifies statements
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
8 that allow a user to interact with a relational database. Vim includes
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
9 features for navigation, indentation and syntax highlighting.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
10
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
11 1. Navigation |sql-navigation|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
12 1.1 Matchit |sql-matchit|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
13 1.2 Text Object Motions |sql-object-motions|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
14 1.3 Predefined Object Motions |sql-predefined-objects|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
15 1.4 Macros |sql-macros|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
16 2. SQL Dialects |sql-dialects|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
17 2.1 SQLSetType |SQLSetType|
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
18 2.2 SQLGetType |SQLGetType|
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
19 2.3 SQL Dialect Default |sql-type-default|
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
20 3. Adding new SQL Dialects |sql-adding-dialects|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
21 4. OMNI SQL Completion |sql-completion|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
22 4.1 Static mode |sql-completion-static|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
23 4.2 Dynamic mode |sql-completion-dynamic|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
24 4.3 Tutorial |sql-completion-tutorial|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
25 4.3.1 Complete Tables |sql-completion-tables|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
26 4.3.2 Complete Columns |sql-completion-columns|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
27 4.3.3 Complete Procedures |sql-completion-procedures|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
28 4.3.4 Complete Views |sql-completion-views|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
29 4.4 Completion Customization |sql-completion-customization|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
30 4.5 SQL Maps |sql-completion-maps|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
31 4.6 Using with other filetypes |sql-completion-filetypes|
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
32
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
33 ==============================================================================
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
34 1. Navigation *sql-navigation*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
35
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
36 The SQL ftplugin provides a number of options to assist with file
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
37 navigation.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
38
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
39
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
40 1.1 Matchit *sql-matchit*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
41 -----------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
42 The matchit plugin (http://www.vim.org/scripts/script.php?script_id=39)
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
43 provides many additional features and can be customized for different
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
44 languages. The matchit plugin is configured by defining a local
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
45 buffer variable, b:match_words. Pressing the % key while on various
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
46 keywords will move the cursor to its match. For example, if the cursor
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
47 is on an "if", pressing % will cycle between the "else", "elseif" and
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
48 "end if" keywords.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
49
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
50 The following keywords are supported: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
51 if
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
52 elseif | elsif
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
53 else [if]
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
54 end if
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
55
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
56 [while condition] loop
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
57 leave
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
58 break
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
59 continue
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
60 exit
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
61 end loop
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
62
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
63 for
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
64 leave
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
65 break
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
66 continue
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
67 exit
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
68 end loop
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
69
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
70 do
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
71 statements
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
72 doend
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
73
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
74 case
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
75 when
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
76 when
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
77 default
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
78 end case
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
79
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
80 merge
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
81 when not matched
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
82 when matched
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
83
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
84 create[ or replace] procedure|function|event
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
85 returns
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
86
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
87
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
88 1.2 Text Object Motions *sql-object-motions*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
89 -----------------------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
90 Vim has a number of predefined keys for working with text |object-motions|.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
91 This filetype plugin attempts to translate these keys to maps which make sense
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
92 for the SQL language.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
93
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
94 The following |Normal| mode and |Visual| mode maps exist (when you edit a SQL
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
95 file): >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
96 ]] move forward to the next 'begin'
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
97 [[ move backwards to the previous 'begin'
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
98 ][ move forward to the next 'end'
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
99 [] move backwards to the previous 'end'
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
100
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
101
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
102 1.3 Predefined Object Motions *sql-predefined-objects*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
103 -----------------------------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
104 Most relational databases support various standard features, tables, indices,
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
105 triggers and stored procedures. Each vendor also has a variety of proprietary
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
106 objects. The next set of maps have been created to help move between these
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
107 objects. Depends on which database vendor you are using, the list of objects
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
108 must be configurable. The filetype plugin attempts to define many of the
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
109 standard objects, plus many additional ones. In order to make this as
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
110 flexible as possible, you can override the list of objects from within your
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
111 |vimrc| with the following: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
112 let g:ftplugin_sql_objects = 'function,procedure,event,table,trigger' .
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
113 \ ',schema,service,publication,database,datatype,domain' .
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
114 \ ',index,subscription,synchronization,view,variable'
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
115
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
116 The following |Normal| mode and |Visual| mode maps have been created which use
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
117 the above list: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
118 ]} move forward to the next 'create <object name>'
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
119 [{ move backward to the previous 'create <object name>'
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
120
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
121 Repeatedly pressing ]} will cycle through each of these create statements: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
122 create table t1 (
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
123 ...
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
124 );
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
125
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
126 create procedure p1
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
127 begin
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
128 ...
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
129 end;
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
130
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
131 create index i1 on t1 (c1);
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
132
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
133 The default setting for g:ftplugin_sql_objects is: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
134 let g:ftplugin_sql_objects = 'function,procedure,event,' .
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
135 \ '\\(existing\\\\|global\\s\\+temporary\\s\\+\\)\\\{,1}' .
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
136 \ 'table,trigger' .
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
137 \ ',schema,service,publication,database,datatype,domain' .
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
138 \ ',index,subscription,synchronization,view,variable'
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
139
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
140 The above will also handle these cases: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
141 create table t1 (
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
142 ...
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
143 );
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
144 create existing table t2 (
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
145 ...
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
146 );
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
147 create global temporary table t3 (
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
148 ...
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
149 );
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
150
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
151 By default, the ftplugin only searches for CREATE statements. You can also
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
152 override this via your |vimrc| with the following: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
153 let g:ftplugin_sql_statements = 'create,alter'
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
154
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
155 The filetype plugin defines three types of comments: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
156 1. --
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
157 2. //
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
158 3. /*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
159 *
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
160 */
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
161
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
162 The following |Normal| mode and |Visual| mode maps have been created to work
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
163 with comments: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
164 ]" move forward to the beginning of a comment
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
165 [" move forward to the end of a comment
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
166
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
167
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
168
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
169 1.4 Macros *sql-macros*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
170 ----------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
171 Vim's feature to find macro definitions, |'define'|, is supported using this
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
172 regular expression: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
173 \c\<\(VARIABLE\|DECLARE\|IN\|OUT\|INOUT\)\>
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
174
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
175 This addresses the following code: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
176 CREATE VARIABLE myVar1 INTEGER;
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
177
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
178 CREATE PROCEDURE sp_test(
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
179 IN myVar2 INTEGER,
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
180 OUT myVar3 CHAR(30),
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
181 INOUT myVar4 NUMERIC(20,0)
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
182 )
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
183 BEGIN
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
184 DECLARE myVar5 INTEGER;
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
185
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
186 SELECT c1, c2, c3
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
187 INTO myVar2, myVar3, myVar4
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
188 FROM T1
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
189 WHERE c4 = myVar1;
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
190 END;
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
191
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
192 Place your cursor on "myVar1" on this line: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
193 WHERE c4 = myVar1;
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
194 ^
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
195
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
196 Press any of the following keys: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
197 [d
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
198 [D
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
199 [CTRL-D
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
200
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
201
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
202 ==============================================================================
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
203 2. SQL Dialects *sql-dialects* *sql-types*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
204 *sybase* *TSQL* *Transact-SQL*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
205 *sqlanywhere*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
206 *oracle* *plsql* *sqlj*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
207 *sqlserver*
2355
84c7eeeb09e2 Fix typos in documentation. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents: 2345
diff changeset
208 *mysql* *postgresql* *psql*
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
209 *informix*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
210
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
211 All relational databases support SQL. There is a portion of SQL that is
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
212 portable across vendors (ex. CREATE TABLE, CREATE INDEX), but there is a
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
213 great deal of vendor specific extensions to SQL. Oracle supports the
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
214 "CREATE OR REPLACE" syntax, column defaults specified in the CREATE TABLE
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
215 statement and the procedural language (for stored procedures and triggers).
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
216
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
217 The default Vim distribution ships with syntax highlighting based on Oracle's
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
218 PL/SQL. The default SQL indent script works for Oracle and SQL Anywhere.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
219 The default filetype plugin works for all vendors and should remain vendor
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
220 neutral, but extendable.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
221
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
222 Vim currently has support for a variety of different vendors, currently this
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
223 is via syntax scripts. Unfortunately, to flip between different syntax rules
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
224 you must either create:
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
225 1. New filetypes
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
226 2. Custom autocmds
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
227 3. Manual steps / commands
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
228
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
229 The majority of people work with only one vendor's database product, it would
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
230 be nice to specify a default in your |vimrc|.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
231
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
232
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
233 2.1 SQLSetType *sqlsettype* *SQLSetType*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
234 --------------
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
235 For the people that work with many different databases, it is nice to be
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
236 able to flip between the various vendors rules (indent, syntax) on a per
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
237 buffer basis, at any time. The ftplugin/sql.vim file defines this function: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
238 SQLSetType
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
239
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
240 Executing this function without any parameters will set the indent and syntax
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
241 scripts back to their defaults, see |sql-type-default|. If you have turned
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
242 off Vi's compatibility mode, |'compatible'|, you can use the <Tab> key to
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
243 complete the optional parameter.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
244
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
245 After typing the function name and a space, you can use the completion to
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
246 supply a parameter. The function takes the name of the Vim script you want to
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
247 source. Using the |cmdline-completion| feature, the SQLSetType function will
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
248 search the |'runtimepath'| for all Vim scripts with a name containing 'sql'.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
249 This takes the guess work out of the spelling of the names. The following are
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
250 examples: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
251 :SQLSetType
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
252 :SQLSetType sqloracle
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
253 :SQLSetType sqlanywhere
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
254 :SQLSetType sqlinformix
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
255 :SQLSetType mysql
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
256
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
257 The easiest approach is to the use <Tab> character which will first complete
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
258 the command name (SQLSetType), after a space and another <Tab>, display a list
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
259 of available Vim script names: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
260 :SQL<Tab><space><Tab>
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
261
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
262
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
263 2.2 SQLGetType *sqlgettype* *SQLGetType*
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
264 --------------
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
265 At anytime you can determine which SQL dialect you are using by calling the
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
266 SQLGetType command. The ftplugin/sql.vim file defines this function: >
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
267 SQLGetType
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
268
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
269 This will echo: >
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
270 Current SQL dialect in use:sqlanywhere
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
271
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
272
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
273 2.3 SQL Dialect Default *sql-type-default*
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
274 -----------------------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
275 As mentioned earlier, the default syntax rules for Vim is based on Oracle
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
276 (PL/SQL). You can override this default by placing one of the following in
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
277 your |vimrc|: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
278 let g:sql_type_default = 'sqlanywhere'
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
279 let g:sql_type_default = 'sqlinformix'
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
280 let g:sql_type_default = 'mysql'
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
281
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
282 If you added the following to your |vimrc|: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
283 let g:sql_type_default = 'sqlinformix'
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
284
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
285 The next time edit a SQL file the following scripts will be automatically
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
286 loaded by Vim: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
287 ftplugin/sql.vim
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
288 syntax/sqlinformix.vim
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
289 indent/sql.vim
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
290 >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
291 Notice indent/sqlinformix.sql was not loaded. There is no indent file
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
292 for Informix, Vim loads the default files if the specified files does not
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
293 exist.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
294
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
295
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
296 ==============================================================================
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
297 3. Adding new SQL Dialects *sql-adding-dialects*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
298
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
299 If you begin working with a SQL dialect which does not have any customizations
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
300 available with the default Vim distribution you can check http://www.vim.org
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
301 to see if any customization currently exist. If not, you can begin by cloning
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
302 an existing script. Read |filetype-plugins| for more details.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
303
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
304 To help identify these scripts, try to create the files with a "sql" prefix.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
305 If you decide you wish to create customizations for the SQLite database, you
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
306 can create any of the following: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
307 Unix
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
308 ~/.vim/syntax/sqlite.vim
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
309 ~/.vim/indent/sqlite.vim
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
310 Windows
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
311 $VIM/vimfiles/syntax/sqlite.vim
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
312 $VIM/vimfiles/indent/sqlite.vim
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
313
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
314 No changes are necessary to the SQLSetType function. It will automatically
21499
3a1ed539ae2a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
315 pick up the new SQL files and load them when you issue the SQLSetType command.
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
316
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
317
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
318 ==============================================================================
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
319 4. OMNI SQL Completion *sql-completion*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
320 *omni-sql-completion*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
321
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
322 Vim 7 includes a code completion interface and functions which allows plugin
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
323 developers to build in code completion for any language. Vim 7 includes
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
324 code completion for the SQL language.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
325
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
326 There are two modes to the SQL completion plugin, static and dynamic. The
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
327 static mode populates the popups with the data generated from current syntax
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
328 highlight rules. The dynamic mode populates the popups with data retrieved
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
329 directly from a database. This includes, table lists, column lists,
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
330 procedures names and more.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
331
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
332 4.1 Static Mode *sql-completion-static*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
333 ---------------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
334 The static popups created contain items defined by the active syntax rules
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
335 while editing a file with a filetype of SQL. The plugin defines (by default)
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
336 various maps to help the user refine the list of items to be displayed.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
337 The defaults static maps are: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
338 imap <buffer> <C-C>a <C-\><C-O>:call sqlcomplete#Map('syntax')<CR><C-X><C-O>
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
339 imap <buffer> <C-C>k <C-\><C-O>:call sqlcomplete#Map('sqlKeyword')<CR><C-X><C-O>
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
340 imap <buffer> <C-C>f <C-\><C-O>:call sqlcomplete#Map('sqlFunction')<CR><C-X><C-O>
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
341 imap <buffer> <C-C>o <C-\><C-O>:call sqlcomplete#Map('sqlOption')<CR><C-X><C-O>
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
342 imap <buffer> <C-C>T <C-\><C-O>:call sqlcomplete#Map('sqlType')<CR><C-X><C-O>
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
343 imap <buffer> <C-C>s <C-\><C-O>:call sqlcomplete#Map('sqlStatement')<CR><C-X><C-O>
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
344
18831
6848b809a26e Runtime file updates.
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
345 The use of "<C-C>" can be user chosen by using the following in your |.vimrc|
6848b809a26e Runtime file updates.
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
346 as it may not work properly on all platforms: >
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
347 let g:ftplugin_sql_omni_key = '<C-C>'
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
348 >
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
349 The static maps (which are based on the syntax highlight groups) follow this
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
350 format: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
351 imap <buffer> <C-C>k <C-\><C-O>:call sqlcomplete#Map('sqlKeyword')<CR><C-X><C-O>
4437
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4264
diff changeset
352 imap <buffer> <C-C>k <C-\><C-O>:call sqlcomplete#Map('sqlKeyword\w*')<CR><C-X><C-O>
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
353
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
354 This command breaks down as: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
355 imap - Create an insert map
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
356 <buffer> - Only for this buffer
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
357 <C-C>k - Your choice of key map
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
358 <C-\><C-O> - Execute one command, return to Insert mode
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
359 :call sqlcomplete#Map( - Allows the SQL completion plugin to perform some
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
360 housekeeping functions to allow it to be used in
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
361 conjunction with other completion plugins.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
362 Indicate which item you want the SQL completion
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
363 plugin to complete.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
364 In this case we are asking the plugin to display
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
365 items from the syntax highlight group
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
366 'sqlKeyword'.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
367 You can view a list of highlight group names to
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
368 choose from by executing the
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
369 :syntax list
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
370 command while editing a SQL file.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
371 'sqlKeyword' - Display the items for the sqlKeyword highlight
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
372 group
4437
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4264
diff changeset
373 'sqlKeyword\w*' - A second option available with Vim 7.4 which
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4264
diff changeset
374 uses a regular expression to determine which
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4264
diff changeset
375 syntax groups to use
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
376 )<CR> - Execute the :let command
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
377 <C-X><C-O> - Trigger the standard omni completion key stroke.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
378 Passing in 'sqlKeyword' instructs the SQL
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
379 completion plugin to populate the popup with
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
380 items from the sqlKeyword highlight group. The
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
381 plugin will also cache this result until Vim is
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
382 restarted. The syntax list is retrieved using
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
383 the syntaxcomplete plugin.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
384
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
385 Using the 'syntax' keyword is a special case. This instructs the
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
386 syntaxcomplete plugin to retrieve all syntax items. So this will effectively
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
387 work for any of Vim's SQL syntax files. At the time of writing this includes
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
388 10 different syntax files for the different dialects of SQL (see section 3
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
389 above, |sql-dialects|).
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
390
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
391 Here are some examples of the entries which are pulled from the syntax files: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
392 All
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
393 - Contains the contents of all syntax highlight groups
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
394 Statements
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
395 - Select, Insert, Update, Delete, Create, Alter, ...
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
396 Functions
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
397 - Min, Max, Trim, Round, Date, ...
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
398 Keywords
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
399 - Index, Database, Having, Group, With
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
400 Options
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
401 - Isolation_level, On_error, Qualify_owners, Fire_triggers, ...
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
402 Types
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
403 - Integer, Char, Varchar, Date, DateTime, Timestamp, ...
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
404
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
405
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
406 4.2 Dynamic Mode *sql-completion-dynamic*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
407 ----------------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
408 Dynamic mode populates the popups with data directly from a database. In
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
409 order for the dynamic feature to be enabled you must have the dbext.vim
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
410 plugin installed, (http://vim.sourceforge.net/script.php?script_id=356).
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
411
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
412 Dynamic mode is used by several features of the SQL completion plugin.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
413 After installing the dbext plugin see the dbext-tutorial for additional
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
414 configuration and usage. The dbext plugin allows the SQL completion plugin
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
415 to display a list of tables, procedures, views and columns. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
416 Table List
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
417 - All tables for all schema owners
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
418 Procedure List
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
419 - All stored procedures for all schema owners
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
420 View List
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
421 - All stored procedures for all schema owners
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
422 Column List
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
423 - For the selected table, the columns that are part of the table
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
424
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
425 To enable the popup, while in INSERT mode, use the following key combinations
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
426 for each group (where <C-C> means hold the CTRL key down while pressing
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
427 the space bar):
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
428 Table List - <C-C>t
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
429 - <C-X><C-O> (the default map assumes tables)
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
430 Stored Procedure List - <C-C>p
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
431 View List - <C-C>v
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
432 Column List - <C-C>c
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
433
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
434 Drilling In / Out - When viewing a popup window displaying the list
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
435 of tables, you can press <Right>, this will
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
436 replace the table currently highlighted with
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
437 the column list for that table.
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
438 - When viewing a popup window displaying the list
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
439 of columns, you can press <Left>, this will
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
440 replace the column list with the list of tables.
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
441 - This allows you to quickly drill down into a
4264
2d1383658bb4 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
442 table to view its columns and back again.
24751
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 21499
diff changeset
443 - <Right> and <Left> can also be chosen via
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
444 your |.vimrc| >
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
445 let g:ftplugin_sql_omni_key_right = '<Right>'
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
446 let g:ftplugin_sql_omni_key_left = '<Left>'
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
447
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
448 The SQL completion plugin caches various lists that are displayed in
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
449 the popup window. This makes the re-displaying of these lists very
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
450 fast. If new tables or columns are added to the database it may become
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
451 necessary to clear the plugins cache. The default map for this is: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
452 imap <buffer> <C-C>R <C-\><C-O>:call sqlcomplete#Map('ResetCache')<CR><C-X><C-O>
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
453
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
454
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
455 4.3 SQL Tutorial *sql-completion-tutorial*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
456 ----------------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
457
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
458 This tutorial is designed to take you through the common features of the SQL
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
459 completion plugin so that: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
460 a) You gain familiarity with the plugin
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
461 b) You are introduced to some of the more common features
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
462 c) Show how to customize it to your preferences
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
463 d) Demonstrate "Best of Use" of the plugin (easiest way to configure).
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
464
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
465 First, create a new buffer: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
466 :e tutorial.sql
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
467
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
468
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
469 Static features
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
470 ---------------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
471 To take you through the various lists, simply enter insert mode, hit:
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
472 <C-C>s (show SQL statements)
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
473 At this point, you can page down through the list until you find "select".
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
474 If you are familiar with the item you are looking for, for example you know
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
475 the statement begins with the letter "s". You can type ahead (without the
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
476 quotes) "se" then press:
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
477 <C-Space>t
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
478 Assuming "select" is highlighted in the popup list press <Enter> to choose
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
479 the entry. Now type:
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
480 * fr<C-C>a (show all syntax items)
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
481 choose "from" from the popup list.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
482
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
483 When writing stored procedures using the "type" list is useful. It contains
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
484 a list of all the database supported types. This may or may not be true
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
485 depending on the syntax file you are using. The SQL Anywhere syntax file
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
486 (sqlanywhere.vim) has support for this: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
487 BEGIN
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
488 DECLARE customer_id <C-C>T <-- Choose a type from the list
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
489
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
490
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
491 Dynamic features
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
492 ----------------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
493 To take advantage of the dynamic features you must first install the
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
494 dbext.vim plugin (http://vim.sourceforge.net/script.php?script_id=356). It
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
495 also comes with a tutorial. From the SQL completion plugin's perspective,
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
496 the main feature dbext provides is a connection to a database. dbext
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
497 connection profiles are the most efficient mechanism to define connection
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
498 information. Once connections have been setup, the SQL completion plugin
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
499 uses the features of dbext in the background to populate the popups.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
500
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
501 What follows assumes dbext.vim has been correctly configured, a simple test
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
502 is to run the command, :DBListTable. If a list of tables is shown, you know
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
503 dbext.vim is working as expected. If not, please consult the dbext.txt
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
504 documentation.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
505
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
506 Assuming you have followed the dbext-tutorial you can press <C-C>t to
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
507 display a list of tables. There is a delay while dbext is creating the table
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
508 list. After the list is displayed press <C-W>. This will remove both the
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
509 popup window and the table name already chosen when the list became active. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
510
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
511 4.3.1 Table Completion: *sql-completion-tables*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
512
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
513 Press <C-C>t to display a list of tables from within the database you
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
514 have connected via the dbext plugin.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
515 NOTE: All of the SQL completion popups support typing a prefix before pressing
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
516 the key map. This will limit the contents of the popup window to just items
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
517 beginning with those characters. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
518
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
519 4.3.2 Column Completion: *sql-completion-columns*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
520
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
521 The SQL completion plugin can also display a list of columns for particular
21499
3a1ed539ae2a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
522 tables. The column completion is triggered via <C-C>c.
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
523
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
524 NOTE: The following example uses <Right> to trigger a column list while
18831
6848b809a26e Runtime file updates.
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
525 the popup window is active.
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
526
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
527 Example of using column completion:
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
528 - Press <C-C>t again to display the list of tables.
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
529 - When the list is displayed in the completion window, press <Right>,
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
530 this will replace the list of tables, with a list of columns for the
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
531 table highlighted (after the same short delay).
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
532 - If you press <Left>, this will again replace the column list with the
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
533 list of tables. This allows you to drill into tables and column lists
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
534 very quickly.
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
535 - Press <Right> again while the same table is highlighted. You will
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
536 notice there is no delay since the column list has been cached. If you
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
537 change the schema of a cached table you can press <C-C>R, which
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
538 clears the SQL completion cache.
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
539 - NOTE: <Right> and <Left> have been designed to work while the
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
540 completion window is active. If the completion popup window is
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
541 not active, a normal <Right> or <Left> will be executed.
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
542
2207
b17bbfa96fa0 Add the settabvar() and gettabvar() functions.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
543 Let's look at how we can build a SQL statement dynamically. A select statement
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
544 requires a list of columns. There are two ways to build a column list using
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
545 the SQL completion plugin. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
546 One column at a time:
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
547 < 1. After typing SELECT press <C-C>t to display a list of tables.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
548 2. Choose a table from the list.
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
549 3. Press <Right> to display a list of columns.
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
550 4. Choose the column from the list and press enter.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
551 5. Enter a "," and press <C-C>c. Generating a column list
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
552 generally requires having the cursor on a table name. The plugin
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
553 uses this name to determine what table to retrieve the column list.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
554 In this step, since we are pressing <C-C>c without the cursor
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
555 on a table name the column list displayed will be for the previous
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
556 table. Choose a different column and move on.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
557 6. Repeat step 5 as often as necessary. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
558 All columns for a table:
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
559 < 1. After typing SELECT press <C-C>t to display a list of tables.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
560 2. Highlight the table you need the column list for.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
561 3. Press <Enter> to choose the table from the list.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
562 4. Press <C-C>l to request a comma separated list of all columns
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
563 for this table.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
564 5. Based on the table name chosen in step 3, the plugin attempts to
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
565 decide on a reasonable table alias. You are then prompted to
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
566 either accept of change the alias. Press OK.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
567 6. The table name is replaced with the column list of the table is
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
568 replaced with the comma separate list of columns with the alias
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
569 prepended to each of the columns.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
570 7. Step 3 and 4 can be replaced by pressing <C-C>L, which has
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
571 a <C-Y> embedded in the map to choose the currently highlighted
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
572 table in the list.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
573
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
574 There is a special provision when writing select statements. Consider the
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
575 following statement: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
576 select *
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
577 from customer c,
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
578 contact cn,
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
579 department as dp,
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
580 employee e,
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
581 site_options so
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
582 where c.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
583
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
584 In INSERT mode after typing the final "c." which is an alias for the
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
585 "customer" table, you can press either <C-C>c or <C-X><C-O>. This will
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
586 popup a list of columns for the customer table. It does this by looking back
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
587 to the beginning of the select statement and finding a list of the tables
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
588 specified in the FROM clause. In this case it notes that in the string
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
589 "customer c", "c" is an alias for the customer table. The optional "AS"
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
590 keyword is also supported, "customer AS c". >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
591
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
592
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
593 4.3.3 Procedure Completion: *sql-completion-procedures*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
594
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
595 Similar to the table list, <C-C>p, will display a list of stored
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
596 procedures stored within the database. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
597
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
598 4.3.4 View Completion: *sql-completion-views*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
599
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
600 Similar to the table list, <C-C>v, will display a list of views in the
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
601 database.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
602
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
603
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
604 4.4 Completion Customization *sql-completion-customization*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
605 ----------------------------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
606
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
607 The SQL completion plugin can be customized through various options set in
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
608 your |vimrc|: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
609 omni_sql_no_default_maps
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
610 < - Default: This variable is not defined
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
611 - If this variable is defined, no maps are created for OMNI
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
612 completion. See |sql-completion-maps| for further discussion.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
613 >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
614 omni_sql_use_tbl_alias
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
615 < - Default: a
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
616 - This setting is only used when generating a comma separated
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
617 column list. By default the map is <C-C>l. When generating
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
618 a column list, an alias can be prepended to the beginning of each
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
619 column, for example: e.emp_id, e.emp_name. This option has three
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
620 settings: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
621 n - do not use an alias
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
622 d - use the default (calculated) alias
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
623 a - ask to confirm the alias name
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
624 <
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
625 An alias is determined following a few rules:
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
626 1. If the table name has an '_', then use it as a separator: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
627 MY_TABLE_NAME --> MTN
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
628 my_table_name --> mtn
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
629 My_table_NAME --> MtN
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
630 < 2. If the table name does NOT contain an '_', but DOES use
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
631 mixed case then the case is used as a separator: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
632 MyTableName --> MTN
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
633 < 3. If the table name does NOT contain an '_', and does NOT
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
634 use mixed case then the first letter of the table is used: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
635 mytablename --> m
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
636 MYTABLENAME --> M
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
637
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
638 omni_sql_ignorecase
2324
0a258a67051d In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents: 2207
diff changeset
639 < - Default: Current setting for 'ignorecase'
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
640 - Valid settings are 0 or 1.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
641 - When entering a few letters before initiating completion, the list
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
642 will be filtered to display only the entries which begin with the
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
643 list of characters. When this option is set to 0, the list will be
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
644 filtered using case sensitivity. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
645
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
646 omni_sql_include_owner
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
647 < - Default: 0, unless dbext.vim 3.00 has been installed
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
648 - Valid settings are 0 or 1.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
649 - When completing tables, procedure or views and using dbext.vim 3.00
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
650 or higher the list of objects will also include the owner name.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
651 When completing these objects and omni_sql_include_owner is enabled
4264
2d1383658bb4 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
652 the owner name will be replaced. >
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
653
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
654 omni_sql_precache_syntax_groups
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
655 < - Default:
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
656 ['syntax','sqlKeyword','sqlFunction','sqlOption','sqlType','sqlStatement']
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
657 - sqlcomplete can be used in conjunction with other completion
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
658 plugins. This is outlined at |sql-completion-filetypes|. When the
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
659 filetype is changed temporarily to SQL, the sqlcompletion plugin
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
660 will cache the syntax groups listed in the List specified in this
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
661 option.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
662 >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
663
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
664 4.5 SQL Maps *sql-completion-maps*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
665 ------------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
666
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
667 The default SQL maps have been described in other sections of this document in
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
668 greater detail. Here is a list of the maps with a brief description of each.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
669
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
670 Static Maps
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
671 -----------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
672 These are maps which use populate the completion list using Vim's syntax
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
673 highlighting rules. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
674 <C-C>a
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
675 < - Displays all SQL syntax items. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
676 <C-C>k
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
677 < - Displays all SQL syntax items defined as 'sqlKeyword'. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
678 <C-C>f
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
679 < - Displays all SQL syntax items defined as 'sqlFunction. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
680 <C-C>o
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
681 < - Displays all SQL syntax items defined as 'sqlOption'. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
682 <C-C>T
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
683 < - Displays all SQL syntax items defined as 'sqlType'. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
684 <C-C>s
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
685 < - Displays all SQL syntax items defined as 'sqlStatement'. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
686
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
687 Dynamic Maps
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
688 ------------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
689 These are maps which use populate the completion list using the dbext.vim
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
690 plugin. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
691 <C-C>t
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
692 < - Displays a list of tables. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
693 <C-C>p
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
694 < - Displays a list of procedures. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
695 <C-C>v
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
696 < - Displays a list of views. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
697 <C-C>c
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
698 < - Displays a list of columns for a specific table. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
699 <C-C>l
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
700 < - Displays a comma separated list of columns for a specific table. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
701 <C-C>L
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
702 < - Displays a comma separated list of columns for a specific table.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
703 This should only be used when the completion window is active. >
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
704 <Right>
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
705 < - Displays a list of columns for the table currently highlighted in
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
706 the completion window. <Right> is not recognized on most Unix
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
707 systems, so this maps is only created on the Windows platform.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
708 If you would like the same feature on Unix, choose a different key
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
709 and make the same map in your vimrc. >
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
710 <Left>
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
711 < - Displays the list of tables.
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
712 <Left> is not recognized on most Unix systems, so this maps is
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
713 only created on the Windows platform. If you would like the same
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
714 feature on Unix, choose a different key and make the same map in
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
715 your vimrc. >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
716 <C-C>R
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
717 < - This maps removes all cached items and forces the SQL completion
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
718 to regenerate the list of items.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
719
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
720 Customizing Maps
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
721 ----------------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
722 You can create as many additional key maps as you like. Generally, the maps
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
723 will be specifying different syntax highlight groups.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
724
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
725 If you do not wish the default maps created or the key choices do not work on
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
726 your platform (often a case on *nix) you define the following variable in
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
727 your |vimrc|: >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
728 let g:omni_sql_no_default_maps = 1
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
729
21499
3a1ed539ae2a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
730 Do not edit ftplugin/sql.vim directly! If you change this file your changes
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
731 will be over written on future updates. Vim has a special directory structure
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
732 which allows you to make customizations without changing the files that are
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
733 included with the Vim distribution. If you wish to customize the maps
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
734 create an after/ftplugin/sql.vim (see |after-directory|) and place the same
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
735 maps from the ftplugin/sql.vim in it using your own key strokes. <C-C> was
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
736 chosen since it will work on both Windows and *nix platforms. On the windows
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
737 platform you can also use <C-Space> or ALT keys.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
738
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
739
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
740 4.6 Using with other filetypes *sql-completion-filetypes*
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
741 ------------------------------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
742
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
743 Many times SQL can be used with different filetypes. For example Perl, Java,
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
744 PHP, Javascript can all interact with a database. Often you need both the SQL
2207
b17bbfa96fa0 Add the settabvar() and gettabvar() functions.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
745 completion and the completion capabilities for the current language you are
b17bbfa96fa0 Add the settabvar() and gettabvar() functions.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
746 editing.
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
747
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
748 This can be enabled easily with the following steps (assuming a Perl file): >
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
749 1. :e test.pl
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
750 2. :set filetype=sql
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
751 3. :set ft=perl
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
752
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
753 Step 1
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
754 ------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
755 Begins by editing a Perl file. Vim automatically sets the filetype to
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
756 "perl". By default, Vim runs the appropriate filetype file
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
757 ftplugin/perl.vim. If you are using the syntax completion plugin by following
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
758 the directions at |ft-syntax-omni| then the |'omnifunc'| option has been set to
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
759 "syntax#Complete". Pressing <C-X><C-O> will display the omni popup containing
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
760 the syntax items for Perl.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
761
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
762 Step 2
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
763 ------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
764 Manually setting the filetype to 'sql' will also fire the appropriate filetype
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
765 files ftplugin/sql.vim. This file will define a number of buffer specific
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
766 maps for SQL completion, see |sql-completion-maps|. Now these maps have
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
767 been created and the SQL completion plugin has been initialized. All SQL
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
768 syntax items have been cached in preparation. The SQL filetype script detects
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
769 we are attempting to use two different completion plugins. Since the SQL maps
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
770 begin with <C-C>, the maps will toggle the |'omnifunc'| when in use. So you
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
771 can use <C-X><C-O> to continue using the completion for Perl (using the syntax
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
772 completion plugin) and <C-C> to use the SQL completion features.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
773
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
774 Step 3
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
775 ------
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
776 Setting the filetype back to Perl sets all the usual "perl" related items back
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
777 as they were.
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
778
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
779
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13963
diff changeset
780 vim:tw=78:ts=8:noet:ft=help:norl: