You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.3 KiB

2 months ago
  1. <!doctype html>
  2. <title>CodeMirror: SQL Mode for CodeMirror</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link rel="stylesheet" href="../../lib/codemirror.css" />
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="../../addon/edit/matchbrackets.js"></script>
  8. <script src="sql.js"></script>
  9. <link rel="stylesheet" href="../../addon/hint/show-hint.css" />
  10. <script src="../../addon/hint/show-hint.js"></script>
  11. <script src="../../addon/hint/sql-hint.js"></script>
  12. <style>
  13. .CodeMirror {
  14. border-top: 1px solid black;
  15. border-bottom: 1px solid black;
  16. }
  17. </style>
  18. <div id=nav>
  19. <a href="https://codemirror.net/5"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
  20. <ul>
  21. <li><a href="../../index.html">Home</a>
  22. <li><a href="../../doc/manual.html">Manual</a>
  23. <li><a href="https://github.com/codemirror/codemirror5">Code</a>
  24. </ul>
  25. <ul>
  26. <li><a href="../index.html">Language modes</a>
  27. <li><a class=active href="#">SQL Mode for CodeMirror</a>
  28. </ul>
  29. </div>
  30. <article>
  31. <h2>SQL Mode for CodeMirror</h2>
  32. <form>
  33. <textarea id="code" name="code">-- SQL Mode for CodeMirror
  34. SELECT SQL_NO_CACHE DISTINCT
  35. @var1 AS `val1`, @'val2', @global.'sql_mode',
  36. 1.1 AS `float_val`, .14 AS `another_float`, 0.09e3 AS `int_with_esp`,
  37. 0xFA5 AS `hex`, x'fa5' AS `hex2`, 0b101 AS `bin`, b'101' AS `bin2`,
  38. DATE '1994-01-01' AS `sql_date`, { T "1994-01-01" } AS `odbc_date`,
  39. 'my string', _utf8'your string', N'her string',
  40. TRUE, FALSE, UNKNOWN
  41. FROM DUAL
  42. -- space needed after '--'
  43. # 1 line comment
  44. /* multiline
  45. comment! */
  46. LIMIT 1 OFFSET 0;
  47. </textarea>
  48. </form>
  49. <p><strong>MIME types defined:</strong>
  50. <code><a href="?mime=text/x-sql">text/x-sql</a></code>,
  51. <code><a href="?mime=text/x-mysql">text/x-mysql</a></code>,
  52. <code><a href="?mime=text/x-mariadb">text/x-mariadb</a></code>,
  53. <code><a href="?mime=text/x-cassandra">text/x-cassandra</a></code>,
  54. <code><a href="?mime=text/x-plsql">text/x-plsql</a></code>,
  55. <code><a href="?mime=text/x-mssql">text/x-mssql</a></code>,
  56. <code><a href="?mime=text/x-hive">text/x-hive</a></code>,
  57. <code><a href="?mime=text/x-pgsql">text/x-pgsql</a></code>,
  58. <code><a href="?mime=text/x-gql">text/x-gql</a></code>,
  59. <code><a href="?mime=text/x-gpsql">text/x-gpsql</a></code>.
  60. <code><a href="?mime=text/x-esper">text/x-esper</a></code>.
  61. <code><a href="?mime=text/x-sqlite">text/x-sqlite</a></code>.
  62. <code><a href="?mime=text/x-sparksql">text/x-sparksql</a></code>.
  63. <code><a href="?mime=text/x-trino">text/x-trino</a></code>.
  64. </p>
  65. <script>
  66. window.onload = function() {
  67. var mime = 'text/x-mariadb';
  68. // get mime type
  69. if (window.location.href.indexOf('mime=') > -1) {
  70. mime = window.location.href.substr(window.location.href.indexOf('mime=') + 5);
  71. }
  72. window.editor = CodeMirror.fromTextArea(document.getElementById('code'), {
  73. mode: mime,
  74. indentWithTabs: true,
  75. smartIndent: true,
  76. lineNumbers: true,
  77. matchBrackets : true,
  78. autofocus: true,
  79. extraKeys: {"Ctrl-Space": "autocomplete"},
  80. hintOptions: {tables: {
  81. users: ["name", "score", "birthDate"],
  82. countries: ["name", "population", "size"]
  83. }}
  84. });
  85. };
  86. </script>
  87. </article>