Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241" Vim syntax file" Language: SQL with SQLite and other additions." Maintainer: Jessica K McIntosh AT gmail DOT com" Last Changed: Thu Jan 23 06:00 PM 2014 EST
" More complete SQL matching with error reporting." Only matches types inside 'CREATE TABLE ();'." Highlights functions. Unknown functions are an error." Based on the SQL syntax files that come with Vim.
if exists('b:current_syntax') finishendif
syn case ignore
" All non-contained SQL syntax.syn cluster sqlALL contains=TOP
" Various error conditions."syn match sqlError "\<\w\+(" " Not a known function.syn match sqlError ")" " Lonely closing paren.syn match sqlError ",\(\_\s*[;)]\)\@=" " Comma before a paren or semicolon.syn match sqlError " $" " Space at the end of a line." Comma before certain words.syn match sqlError ",\_\s*\(\<\(asc\|desc\|exists\|for\|from\)\>\)\@="syn match sqlError ",\_\s*\(\<\(group by\|into\|limit\|order\)\>\)\@="syn match sqlError ",\_\s*\(\<\(table\|using\|where\)\>\)\@="
" Special words.syn keyword sqlSpecial false null true
" Keywordssyn keyword sqlKeyword access add after aggregate as asc authorizationsyn keyword sqlKeyword begin by cache cascade check cluster collatesyn keyword sqlKeyword collation column compress conflict connect connectionsyn keyword sqlKeyword constraint current cursor database debug decimalsyn keyword sqlKeyword default desc each else elsif escape exceptionsyn keyword sqlKeyword exclusive explain external file for foreign from functionsyn keyword sqlKeyword group having identified if immediate increment indexsyn keyword sqlKeyword initial inner into is join key left level loopsyn keyword sqlKeyword maxextents mode modify nocompress nowait object ofsyn keyword sqlKeyword off offline on online option order outer oversyn keyword sqlKeyword partition pctfreesyn keyword sqlKeyword primary privileges procedure public referencessyn keyword sqlKeyword referencing release resource return role row rowidsyn keyword sqlKeyword rowlabel rownum rows schema session share sizesyn keyword sqlKeyword start successful synonym then to transaction triggersyn keyword sqlKeyword uid user using validate values view virtual wheneversyn keyword sqlKeyword where withsyn match sqlKeyword "\<prompt\>"syn match sqlKeyword "\<glob\>"" Do special things with CREATE TABLE ( below.syn match sqlKeyword "\<table\>"
" SQLite Pragmas - Treat them as keywords.syn keyword sqlKeyword auto_vacuum automatic_index cache_sizesyn keyword sqlKeyword case_sensitive_like checkpoint_fullfsyncsyn keyword sqlKeyword collation_list compile_options count_changessyn keyword sqlKeyword database_list default_cache_sizesyn keyword sqlKeyword empty_result_callbacks encoding foreign_key_listsyn keyword sqlKeyword foreign_keys freelist_count full_column_namessyn keyword sqlKeyword fullfsync ignore_check_constraintssyn keyword sqlKeyword incremental_vacuum index_info index_listsyn keyword sqlKeyword integrity_check journal_mode journal_size_limitsyn keyword sqlKeyword legacy_file_format locking_mode max_page_countsyn keyword sqlKeyword page_count page_size parser_trace quick_checksyn keyword sqlKeyword read_uncommitted recursive_triggerssyn keyword sqlKeyword reverse_unordered_selects schema_versionsyn keyword sqlKeyword secure_delete short_column_names synchronoussyn keyword sqlKeyword table_info temp_store temp_store_directorysyn keyword sqlKeyword user_version vdbe_listing vdbe_tracesyn keyword sqlKeyword wal_autocheckpoint wal_checkpoint writable_schema
" Operatorssyn keyword sqlOperator all and any between case distinct elif else endsyn keyword sqlOperator exit exists if in intersect is like match matchessyn keyword sqlOperator minus not or out prior regexp some then unionsyn keyword sqlOperator unique whensyn match sqlOperator "||\|:="
" Conditionalssyn match sqlConditional "=\|<\|>\|+\|-"
" Unknown functions.syn match sqlUnknownFunc "\<\w\+(\@="
" Functions - Only valid with a '(' after them.syn match sqlFunction "\<\(abs\|acos\|asin\|atan2\?\|avg\|cardinality\)(\@="syn match sqlFunction "\<\(cast\|changes\|char_length\|character_length\)(\@="syn match sqlFunction "\<\(coalesce\|concat\|cos\|count\|\(date\)\?\(time\)\?\)(\@="syn match sqlFunction "\<\(exp\|filetoblob\|filetoclob\|floor\|glob\|group_concat\)(\@="syn match sqlFunction "\<\(hex\|ifnull\|initcap\|isnull\|julianday\|last_insert_rowid\)(\@="syn match sqlFunction "\<\(length\|log10\|logn\|lower\|lpad\|ltrin\|max\|min\)(\@="syn match sqlFunction "\<\(mod\|nullif\|octet_length\|pow\|quote\|random\)(\@="syn match sqlFunction "\<\(range\|replace\|root\|round\|rpad\|sin\|soundex\)(\@="syn match sqlFunction "\<\(sqrtstdev\|strftime\|substr\|substring\|sum\|sysdate\|tan\)(\@="syn match sqlFunction "\<\(to_char\|to_date\|to_number\|total\|trim\|trunc\|typeof\)(\@="syn match sqlFunction "\<\(upper\|variance\)(\@="
" Oracle DBMS functions.syn match sqlFunction "\<dbms_\w\+\.\w\+(\@="
" Oracle Exception Functions.syn match sqlFunction "\<raise_application_error(\@="
" SQLite Functionssyn match sqlFunction "\<\(last_insert_rowid\|load_extension\|randomblob\)(\@="syn match sqlFunction "\<\(sqlite_compileoption_get\|sqlite_compileoption_used\)(\@="syn match sqlFunction "\<\(sqlite_source_id\|sqlite_version\|sqlite_version\)(\@="syn match sqlFunction "\<\(zeroblob\|ltrim\|rtrim\)(\@="
" SQLite Command Line Client Functionssyn match sqlFunction "^\.\w\+"
" Statementssyn keyword sqlStatement alter analyze audit begin comment commit deletesyn keyword sqlStatement drop execute explain grant insert lock noauditsyn keyword sqlStatement rename revoke rollback savepoint selectsyn keyword sqlStatement truncate update vacuumsyn match sqlStatement "\<\(replace\|create\)\>"
" SQLite Statementssyn keyword sqlStatement attach detach indexed pragma reindex
" Types - Only matched inside 'CREATE TABLE ();'.syn keyword sqlType contained bigint bit blob bool boolean byte charsyn keyword sqlType contained clob date datetime dec decimal enumsyn keyword sqlType contained float int int8 integer interval longsyn keyword sqlType contained longblob longtext lvarchar mediumblobsyn keyword sqlType contained mediumint mediumtext mlslabel moneysyn keyword sqlType contained multiset nchar number numeric nvarcharsyn keyword sqlType contained raw real rowid serial serial8 setsyn keyword sqlType contained smallfloat smallint text timesyn keyword sqlType contained timestamp tinyblob tinyint tinytextsyn keyword sqlType contained varchar varchar2 varray yearsyn match sqlType contained "\<\(character\|double\|varying\)\>"syn match sqlType contained "\<character\s\+varying\>"syn match sqlType contained "\<double\s\+precision\>"
" Oracle Variablessyn match sqlVariable "&\a\w\+"syn match sqlVariable ":\w\+"syn match sqlVariable "SQL%\w\+"
" Stringssyn region sqlString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=sqlVariablesyn region sqlString start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=sqlVariablesyn region sqlString start=+`+ skip=+\\\\\|\\`+ end=+`+ contains=sqlVariable
" Numberssyn match sqlNumber "-\=\<[0-9]*\>"syn match sqlNumber "-\=\<[0-9]*\.[0-9]*\>"syn match sqlNumber "-\=\<[0-9][0-9]*e[+-]\=[0-9]*\>"syn match sqlNumber "-\=\<[0-9]*\.[0-9]*e[+-]\=[0-9]*\>"syn match sqlNumber "\<0x[abcdef0-9]*\>"
" Todosyn keyword sqlTodo contained DEBUG FIXME NOTE TODO XXX
" Commentssyn region sqlComment start="/\*" end="\*/" contains=sqlTodosyn match sqlComment "--.*$" contains=sqlTodosyn match sqlComment "rem.*$" contains=sqlTodo
" Mark correct paren use. Different colors for different purposes.syn region sqlParens transparent matchgroup=sqlParen start="(" end=")"syn match sqlParenEmpty "()"syn region sqlParens transparent matchgroup=sqlParenFunc start="\(\<\w\+\>\)\@<=(" end=")"
" Highlight types correctly inside create table and procedure statements." All other SQL is properly highlighted as well.syn region sqlTypeParens contained matchgroup=sqlType start="(" end=")" contains=@sqlALLsyn match sqlTypeMatch contained "\(\(^\|[,(]\)\s*\S\+\s\+\)\@<=\w\+\(\s*([^)]\+)\)\?" contains=sqlType,sqlTypeParenssyn match sqlTypeMatch contained "\(\(^\|[,(]\)\s*\S\+\s\+\)\@<=character\s\+varying\s*([^)]\+)" contains=sqlType,sqlTypeParenssyn region sqlTypeRegion matchgroup=sqlParen start="\(create\s\+table\s\+[^(]\+\s\+\)\@<=(" end=")" contains=@sqlALL,sqlTypeMatchsyn region sqlTypeRegion matchgroup=sqlParen start="\(create\s\+\(or\s\+replace\s\+\)\?procedure\s\+[^(]\+\s*\)\@<=(" end=")" contains=@sqlALL,sqlTypeMatch
" SQL Embedded in a statement.syn region sqlquoteRegion matchgroup=sqlParen start="\(execute\s\+immediate\s*\)\@<=('" end="')" contains=@sqlALL
" Special Oracle Statementssyn match sqlStatement "^\s*\(prompt\|spool\)\>" nextgroup=sqlAnyStringsyn match sqlStatement "^\s*accept\s\+" nextgroup=sqlAnyVariablesyn match sqlStatement "declare\s\+" nextgroup=sqlDeclaresyn region sqlDeclare contained matchgroup=sqlVariable start="\a\w\+" end="$" contains=@sqlALL,sqlTypesyn match sqlOperator "^@" nextgroup=sqlAnyStringsyn match sqlAnyVariable contained "\a\w\+"syn match sqlAnyString contained ".*" contains=sqlVariable
syn region sqlSetRegion matchgroup=sqlStatement start="^\s*set\>" matchgroup=NONE end="$" contains=sqlSetOptions,sqlSetValuessyn keyword sqlSetOptions contained autorecovery colsep copytypecheck describe escchar flaggersyn keyword sqlSetOptions contained instance logsource long null recsep recsepcharsyn keyword sqlSetOptions containedsyn match sqlSetOptions contained "\<\(app\w*\|array\w*\|auto\w*\|autop\w*\)\>"syn match sqlSetOptions contained "\<\(autot\w*\|blo\w*\|cmds\w*\|con\w*\|copyc\w*\)\>"syn match sqlSetOptions contained "\<\(def\w*\|echo\|editf\w*\|emb\w*\|errorl\w*\|esc\w*\)\>"syn match sqlSetOptions contained "\<\(feed\w*\|flu\w*\|hea\w*\|heads\w*\|lin\w*\)\>"syn match sqlSetOptions contained "\<\(lobof\w*\|longc\w*\|mark\w*\|newp\w*\|numf\w*\)\>"syn match sqlSetOptions contained "\<\(pages\w*\|pau\w*\|serverout\w*\|shift\w*\|show\w*\)\>"syn match sqlSetOptions contained "\<\(sqlbl\w*\|sqlc\w*\|sqlco\w*\|sqln\w*\|sqlpluscompat\w*\)\>"syn match sqlSetOptions contained "\<\(sqlpre\w*\|sqlp\w*\|sqlt\w*\|suf\w*\|tab\)\>"syn match sqlSetOptions contained "\<\(term\w*\|timi\w*\|und\w*\|ver\w*\|wra\w\?\)\>"syn match sqlSetOptions contained "\<\(xquery\s\+\(baseuri\|ordering\|node\|context\)\)\>"syn keyword sqlSetValues contained all body byreference byvalue defaultsyn keyword sqlSetValues contained entry fill head html identifier indentsyn keyword sqlSetValues contained linenum local none off on size table truncatesyn match sqlSetValues contained "\<\(ea\w*\|wr\w*\|imm\w*\|trace\w*\|expl\w*\|stat\w*\)\>"syn match sqlSetValues contained "\<\(intermed\w*\|pre\w*\|unl\w*\|for\w*\|wra\w*\|wor\w\?\)\>"syn match sqlSetValues contained "\<\(vis\w*\|inv\w*\)\>"syn match sqlSetValues contained "\<\(\(un\)\?ordered\)\>"
let sh_minlines = 200let sh_maxlines = 2 * sh_minlinesexec 'syn sync minlines=' . sh_minlines . ' maxlines=' . sh_maxlines
highlight def link sqlComment Commenthighlight def link sqlError Errorhighlight def link sqlFunction Functionhighlight def link sqlUnknownFunc Exceptionhighlight def link sqlKeyword Specialhighlight def link sqlConditional Conditionalhighlight def link sqlNumber Numberhighlight def link sqlOperator Operatorhighlight def link sqlParen Commenthighlight def link sqlParenEmpty Operatorhighlight def link sqlParenFunc Functionhighlight def link sqlSpecial Keywordhighlight def link sqlStatement Statementhighlight def link sqlString Stringhighlight def link sqlTodo Todohighlight def link sqlType Typehighlight def link sqlVariable Identifier
highlight def link sqlAnyString sqlStringhighlight def link sqlAnyVariable sqlVariablehighlight def link sqlSetOptions Operatorhighlight def link sqlSetValues Special
let b:current_syntax = 'sql'