sql.js 14 KB

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