[d24f17c] | 1 | /*
|
---|
| 2 | Language: SQL More (mix of MySQL, Oracle, etc)
|
---|
| 3 | Contributors: Nikolay Lisienko <info@neor.ru>, Heiko August <post@auge8472.de>, Travis Odom <travis.a.odom@gmail.com>, Vadimtro <vadimtro@yahoo.com>, Benjamin Auder <benjamin.auder@gmail.com>
|
---|
| 4 | Website: https://en.wikipedia.org/wiki/SQL
|
---|
| 5 | Category: database
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | /*
|
---|
| 9 |
|
---|
| 10 | This is a preservation of the old bloated SQL grammar which includes pretty much
|
---|
| 11 | the kitchen sink because no one was keeping track of which keywords belong to
|
---|
| 12 | which databases. This is likely to be removed in the future.
|
---|
| 13 |
|
---|
| 14 | - Oracle SQL should be factored into it's own 3rd party grammar.
|
---|
| 15 | - MySQL should be factored out into it's own 3rd party grammar.
|
---|
| 16 |
|
---|
| 17 | */
|
---|
| 18 |
|
---|
| 19 | function sql_more(hljs) {
|
---|
| 20 | var COMMENT_MODE = hljs.COMMENT('--', '$');
|
---|
| 21 | return {
|
---|
| 22 | name: 'SQL (more)',
|
---|
| 23 | aliases: ["mysql", "oracle"],
|
---|
| 24 | disableAutodetect: true,
|
---|
| 25 | case_insensitive: true,
|
---|
| 26 | illegal: /[<>{}*]/,
|
---|
| 27 | contains: [
|
---|
| 28 | {
|
---|
| 29 | beginKeywords:
|
---|
| 30 | 'begin end start commit rollback savepoint lock alter create drop rename call ' +
|
---|
| 31 | 'delete do handler insert load replace select truncate update set show pragma grant ' +
|
---|
| 32 | 'merge describe use explain help declare prepare execute deallocate release ' +
|
---|
| 33 | 'unlock purge reset change stop analyze cache flush optimize repair kill ' +
|
---|
| 34 | 'install uninstall checksum restore check backup revoke comment values with',
|
---|
| 35 | end: /;/, endsWithParent: true,
|
---|
| 36 | keywords: {
|
---|
| 37 | $pattern: /[\w\.]+/,
|
---|
| 38 | keyword:
|
---|
| 39 | 'as abort abs absolute acc acce accep accept access accessed accessible account acos action activate add ' +
|
---|
| 40 | 'addtime admin administer advanced advise aes_decrypt aes_encrypt after agent aggregate ali alia alias ' +
|
---|
| 41 | 'all allocate allow alter always analyze ancillary and anti any anydata anydataset anyschema anytype apply ' +
|
---|
| 42 | 'archive archived archivelog are as asc ascii asin assembly assertion associate asynchronous at atan ' +
|
---|
| 43 | 'atn2 attr attri attrib attribu attribut attribute attributes audit authenticated authentication authid ' +
|
---|
| 44 | 'authors auto autoallocate autodblink autoextend automatic availability avg backup badfile basicfile ' +
|
---|
| 45 | 'before begin beginning benchmark between bfile bfile_base big bigfile bin binary_double binary_float ' +
|
---|
| 46 | 'binlog bit_and bit_count bit_length bit_or bit_xor bitmap blob_base block blocksize body both bound ' +
|
---|
| 47 | 'bucket buffer_cache buffer_pool build bulk by byte byteordermark bytes cache caching call calling cancel ' +
|
---|
| 48 | 'capacity cascade cascaded case cast catalog category ceil ceiling chain change changed char_base ' +
|
---|
| 49 | 'char_length character_length characters characterset charindex charset charsetform charsetid check ' +
|
---|
| 50 | 'checksum checksum_agg child choose chr chunk class cleanup clear client clob clob_base clone close ' +
|
---|
| 51 | 'cluster_id cluster_probability cluster_set clustering coalesce coercibility col collate collation ' +
|
---|
| 52 | 'collect colu colum column column_value columns columns_updated comment commit compact compatibility ' +
|
---|
| 53 | 'compiled complete composite_limit compound compress compute concat concat_ws concurrent confirm conn ' +
|
---|
| 54 | 'connec connect connect_by_iscycle connect_by_isleaf connect_by_root connect_time connection ' +
|
---|
| 55 | 'consider consistent constant constraint constraints constructor container content contents context ' +
|
---|
| 56 | 'contributors controlfile conv convert convert_tz corr corr_k corr_s corresponding corruption cos cost ' +
|
---|
| 57 | 'count count_big counted covar_pop covar_samp cpu_per_call cpu_per_session crc32 create creation ' +
|
---|
| 58 | 'critical cross cube cume_dist curdate current current_date current_time current_timestamp current_user ' +
|
---|
| 59 | 'cursor curtime customdatum cycle data database databases datafile datafiles datalength date_add ' +
|
---|
| 60 | 'date_cache date_format date_sub dateadd datediff datefromparts datename datepart datetime2fromparts ' +
|
---|
| 61 | 'day day_to_second dayname dayofmonth dayofweek dayofyear days db_role_change dbtimezone ddl deallocate ' +
|
---|
| 62 | 'declare decode decompose decrement decrypt deduplicate def defa defau defaul default defaults ' +
|
---|
| 63 | 'deferred defi defin define degrees delayed delegate delete delete_all delimited demand dense_rank ' +
|
---|
| 64 | 'depth dequeue des_decrypt des_encrypt des_key_file desc descr descri describ describe descriptor ' +
|
---|
| 65 | 'deterministic diagnostics difference dimension direct_load directory disable disable_all ' +
|
---|
| 66 | 'disallow disassociate discardfile disconnect diskgroup distinct distinctrow distribute distributed div ' +
|
---|
| 67 | 'do document domain dotnet double downgrade drop dumpfile duplicate duration each edition editionable ' +
|
---|
| 68 | 'editions element ellipsis else elsif elt empty enable enable_all enclosed encode encoding encrypt ' +
|
---|
| 69 | 'end end-exec endian enforced engine engines enqueue enterprise entityescaping eomonth error errors ' +
|
---|
| 70 | 'escaped evalname evaluate event eventdata events except exception exceptions exchange exclude excluding ' +
|
---|
| 71 | 'execu execut execute exempt exists exit exp expire explain explode export export_set extended extent external ' +
|
---|
| 72 | 'external_1 external_2 externally extract failed failed_login_attempts failover failure far fast ' +
|
---|
| 73 | 'feature_set feature_value fetch field fields file file_name_convert filesystem_like_logging final ' +
|
---|
| 74 | 'finish first first_value fixed flash_cache flashback floor flush following follows for forall force foreign ' +
|
---|
| 75 | 'form forma format found found_rows freelist freelists freepools fresh from from_base64 from_days ' +
|
---|
| 76 | 'ftp full function general generated get get_format get_lock getdate getutcdate global global_name ' +
|
---|
| 77 | 'globally go goto grant grants greatest group group_concat group_id grouping grouping_id groups ' +
|
---|
| 78 | 'gtid_subtract guarantee guard handler hash hashkeys having hea head headi headin heading heap help hex ' +
|
---|
| 79 | 'hierarchy high high_priority hosts hour hours http id ident_current ident_incr ident_seed identified ' +
|
---|
| 80 | 'identity idle_time if ifnull ignore iif ilike ilm immediate import in include including increment ' +
|
---|
| 81 | 'index indexes indexing indextype indicator indices inet6_aton inet6_ntoa inet_aton inet_ntoa infile ' +
|
---|
| 82 | 'initial initialized initially initrans inmemory inner innodb input insert install instance instantiable ' +
|
---|
| 83 | 'instr interface interleaved intersect into invalidate invisible is is_free_lock is_ipv4 is_ipv4_compat ' +
|
---|
| 84 | 'is_not is_not_null is_used_lock isdate isnull isolation iterate java join json json_exists ' +
|
---|
| 85 | 'keep keep_duplicates key keys kill language large last last_day last_insert_id last_value lateral lax lcase ' +
|
---|
| 86 | 'lead leading least leaves left len lenght length less level levels library like like2 like4 likec limit ' +
|
---|
| 87 | 'lines link list listagg little ln load load_file lob lobs local localtime localtimestamp locate ' +
|
---|
| 88 | 'locator lock locked log log10 log2 logfile logfiles logging logical logical_reads_per_call ' +
|
---|
| 89 | 'logoff logon logs long loop low low_priority lower lpad lrtrim ltrim main make_set makedate maketime ' +
|
---|
| 90 | 'managed management manual map mapping mask master master_pos_wait match matched materialized max ' +
|
---|
| 91 | 'maxextents maximize maxinstances maxlen maxlogfiles maxloghistory maxlogmembers maxsize maxtrans ' +
|
---|
| 92 | 'md5 measures median medium member memcompress memory merge microsecond mid migration min minextents ' +
|
---|
| 93 | 'minimum mining minus minute minutes minvalue missing mod mode model modification modify module monitoring month ' +
|
---|
| 94 | 'months mount move movement multiset mutex name name_const names nan national native natural nav nchar ' +
|
---|
| 95 | 'nclob nested never new newline next nextval no no_write_to_binlog noarchivelog noaudit nobadfile ' +
|
---|
| 96 | 'nocheck nocompress nocopy nocycle nodelay nodiscardfile noentityescaping noguarantee nokeep nologfile ' +
|
---|
| 97 | 'nomapping nomaxvalue nominimize nominvalue nomonitoring none noneditionable nonschema noorder ' +
|
---|
| 98 | 'nopr nopro noprom nopromp noprompt norely noresetlogs noreverse normal norowdependencies noschemacheck ' +
|
---|
| 99 | 'noswitch not nothing notice notnull notrim novalidate now nowait nth_value nullif nulls num numb numbe ' +
|
---|
| 100 | 'nvarchar nvarchar2 object ocicoll ocidate ocidatetime ociduration ociinterval ociloblocator ocinumber ' +
|
---|
| 101 | 'ociref ocirefcursor ocirowid ocistring ocitype oct octet_length of off offline offset oid oidindex old ' +
|
---|
| 102 | 'on online only opaque open operations operator optimal optimize option optionally or oracle oracle_date ' +
|
---|
| 103 | 'oradata ord ordaudio orddicom orddoc order ordimage ordinality ordvideo organization orlany orlvary ' +
|
---|
| 104 | 'out outer outfile outline output over overflow overriding package pad parallel parallel_enable ' +
|
---|
| 105 | 'parameters parent parse partial partition partitions pascal passing password password_grace_time ' +
|
---|
| 106 | 'password_lock_time password_reuse_max password_reuse_time password_verify_function patch path patindex ' +
|
---|
| 107 | 'pctincrease pctthreshold pctused pctversion percent percent_rank percentile_cont percentile_disc ' +
|
---|
| 108 | 'performance period period_add period_diff permanent physical pi pipe pipelined pivot pluggable plugin ' +
|
---|
| 109 | 'policy position post_transaction pow power pragma prebuilt precedes preceding precision prediction ' +
|
---|
| 110 | 'prediction_cost prediction_details prediction_probability prediction_set prepare present preserve ' +
|
---|
| 111 | 'prior priority private private_sga privileges procedural procedure procedure_analyze processlist ' +
|
---|
| 112 | 'profiles project prompt protection public publishingservername purge quarter query quick quiesce quota ' +
|
---|
| 113 | 'quotename radians raise rand range rank raw read reads readsize rebuild record records ' +
|
---|
| 114 | 'recover recovery recursive recycle redo reduced ref reference referenced references referencing refresh ' +
|
---|
| 115 | 'regexp_like register regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy ' +
|
---|
| 116 | 'reject rekey relational relative relaylog release release_lock relies_on relocate rely rem remainder rename ' +
|
---|
| 117 | 'repair repeat replace replicate replication required reset resetlogs resize resource respect restore ' +
|
---|
| 118 | 'restricted result result_cache resumable resume retention return returning returns reuse reverse revoke ' +
|
---|
| 119 | 'right rlike role roles rollback rolling rollup round row row_count rowdependencies rowid rownum rows ' +
|
---|
| 120 | 'rtrim rules safe salt sample save savepoint sb1 sb2 sb4 scan schema schemacheck scn scope scroll ' +
|
---|
| 121 | 'sdo_georaster sdo_topo_geometry search sec_to_time second seconds section securefile security seed segment select ' +
|
---|
| 122 | 'self semi sequence sequential serializable server servererror session session_user sessions_per_user set ' +
|
---|
| 123 | 'sets settings sha sha1 sha2 share shared shared_pool short show shrink shutdown si_averagecolor ' +
|
---|
| 124 | 'si_colorhistogram si_featurelist si_positionalcolor si_stillimage si_texture siblings sid sign sin ' +
|
---|
| 125 | 'size size_t sizes skip slave sleep smalldatetimefromparts smallfile snapshot some soname sort soundex ' +
|
---|
| 126 | 'source space sparse spfile split sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows ' +
|
---|
| 127 | 'sql_small_result sql_variant_property sqlcode sqldata sqlerror sqlname sqlstate sqrt square standalone ' +
|
---|
| 128 | 'standby start starting startup statement static statistics stats_binomial_test stats_crosstab ' +
|
---|
| 129 | 'stats_ks_test stats_mode stats_mw_test stats_one_way_anova stats_t_test_ stats_t_test_indep ' +
|
---|
| 130 | 'stats_t_test_one stats_t_test_paired stats_wsr_test status std stddev stddev_pop stddev_samp stdev ' +
|
---|
| 131 | 'stop storage store stored str str_to_date straight_join strcmp strict string struct stuff style subdate ' +
|
---|
| 132 | 'subpartition subpartitions substitutable substr substring subtime subtring_index subtype success sum ' +
|
---|
| 133 | 'suspend switch switchoffset switchover sync synchronous synonym sys sys_xmlagg sysasm sysaux sysdate ' +
|
---|
| 134 | 'sysdatetimeoffset sysdba sysoper system system_user sysutcdatetime table tables tablespace tablesample tan tdo ' +
|
---|
| 135 | 'template temporary terminated tertiary_weights test than then thread through tier ties time time_format ' +
|
---|
| 136 | 'time_zone timediff timefromparts timeout timestamp timestampadd timestampdiff timezone_abbr ' +
|
---|
| 137 | 'timezone_minute timezone_region to to_base64 to_date to_days to_seconds todatetimeoffset trace tracking ' +
|
---|
| 138 | 'transaction transactional translate translation treat trigger trigger_nestlevel triggers trim truncate ' +
|
---|
| 139 | 'try_cast try_convert try_parse type ub1 ub2 ub4 ucase unarchived unbounded uncompress ' +
|
---|
| 140 | 'under undo unhex unicode uniform uninstall union unique unix_timestamp unknown unlimited unlock unnest unpivot ' +
|
---|
| 141 | 'unrecoverable unsafe unsigned until untrusted unusable unused update updated upgrade upped upper upsert ' +
|
---|
| 142 | 'url urowid usable usage use use_stored_outlines user user_data user_resources users using utc_date ' +
|
---|
| 143 | 'utc_timestamp uuid uuid_short validate validate_password_strength validation valist value values var ' +
|
---|
| 144 | 'var_samp varcharc vari varia variab variabl variable variables variance varp varraw varrawc varray ' +
|
---|
| 145 | 'verify version versions view virtual visible void wait wallet warning warnings week weekday weekofyear ' +
|
---|
| 146 | 'wellformed when whene whenev wheneve whenever where while whitespace window with within without work wrapped ' +
|
---|
| 147 | 'xdb xml xmlagg xmlattributes xmlcast xmlcolattval xmlelement xmlexists xmlforest xmlindex xmlnamespaces ' +
|
---|
| 148 | 'xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltype xor year year_to_month years yearweek',
|
---|
| 149 | literal:
|
---|
| 150 | 'true false null unknown',
|
---|
| 151 | built_in:
|
---|
| 152 | 'array bigint binary bit blob bool boolean char character date dec decimal float int int8 integer interval number ' +
|
---|
| 153 | 'numeric real record serial serial8 smallint text time timestamp tinyint varchar varchar2 varying void'
|
---|
| 154 | },
|
---|
| 155 | contains: [
|
---|
| 156 | {
|
---|
| 157 | className: 'string',
|
---|
| 158 | begin: '\'', end: '\'',
|
---|
| 159 | contains: [{begin: '\'\''}]
|
---|
| 160 | },
|
---|
| 161 | {
|
---|
| 162 | className: 'string',
|
---|
| 163 | begin: '"', end: '"',
|
---|
| 164 | contains: [{begin: '""'}]
|
---|
| 165 | },
|
---|
| 166 | {
|
---|
| 167 | className: 'string',
|
---|
| 168 | begin: '`', end: '`'
|
---|
| 169 | },
|
---|
| 170 | hljs.C_NUMBER_MODE,
|
---|
| 171 | hljs.C_BLOCK_COMMENT_MODE,
|
---|
| 172 | COMMENT_MODE,
|
---|
| 173 | hljs.HASH_COMMENT_MODE
|
---|
| 174 | ]
|
---|
| 175 | },
|
---|
| 176 | hljs.C_BLOCK_COMMENT_MODE,
|
---|
| 177 | COMMENT_MODE,
|
---|
| 178 | hljs.HASH_COMMENT_MODE
|
---|
| 179 | ]
|
---|
| 180 | };
|
---|
| 181 | }
|
---|
| 182 |
|
---|
| 183 | module.exports = sql_more;
|
---|