| 1 | <!DOCTYPE html> |
| 2 | <html><head> |
| 3 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
| 4 | <title>test.sql</title> |
| 5 | <meta name="generator" content="KF5::SyntaxHighlighting - Definition (SQL) - Theme (Breeze Light)"/> |
| 6 | </head><body style="background-color:#ffffff;color:#1f1c1b"><pre> |
| 7 | <span style="color:#898887">-- comment</span> |
| 8 | |
| 9 | <span style="font-weight:bold">CREATE</span> <span style="font-weight:bold">TABLE</span> stuff <span style="font-weight:bold">COLUMNS</span>(col1 <span style="color:#0057ae">INT</span>, col2 <span style="color:#0057ae">Varchar</span>); |
| 10 | <span style="font-weight:bold">SELECT</span> <span style="color:#ca60ca">*</span> <span style="font-weight:bold">FROM</span> stuff <span style="font-weight:bold">WHERE</span> <span style="font-weight:bold">id</span> <span style="color:#ca60ca">=</span> <span style="color:#bf0303">'string'</span>; |
| 11 | <span style="font-weight:bold">select</span> <span style="color:#ca60ca">*</span> <span style="font-weight:bold">from</span> stuff <span style="font-weight:bold">where</span> <span style="font-weight:bold">id</span> <span style="color:#ca60ca"><</span> <span style="color:#b08000">0.42</span>; |
| 12 | <span style="font-weight:bold">Select</span> col1, col2 <span style="font-weight:bold">From</span> stuff <span style="font-weight:bold">Where</span> stuff.col1 <span style="font-weight:bold">IS</span> <span style="font-weight:bold">NOT</span> <span style="font-weight:bold">NuLL</span>; |
| 13 | |
| 14 | <span style="font-weight:bold">CREATE</span> <span style="font-weight:bold">TABLE</span> Persons ( |
| 15 | <span style="font-weight:bold">ID</span> <span style="color:#0057ae">int</span> <span style="font-weight:bold">NOT</span> <span style="font-weight:bold">NULL</span> AUTO_INCREMENT, |
| 16 | LastName <span style="color:#0057ae">varchar</span>(<span style="color:#b08000">255</span>) <span style="font-weight:bold">NOT</span> <span style="font-weight:bold">NULL</span>, |
| 17 | FirstName <span style="color:#0057ae">varchar</span>(<span style="color:#b08000">255</span>), |
| 18 | Age <span style="color:#0057ae">int</span>, |
| 19 | <span style="font-weight:bold">PRIMARY</span> <span style="font-weight:bold">KEY</span> (<span style="font-weight:bold">ID</span>) |
| 20 | <span style="font-weight:bold">CONSTRAINT</span> CHK_Person <span style="font-weight:bold">CHECK</span> (Age<span style="color:#ca60ca">>=</span><span style="color:#b08000">18</span> <span style="font-weight:bold">AND</span> City<span style="color:#ca60ca">=</span><span style="color:#bf0303">'Sandnes'</span>) |
| 21 | ); |
| 22 | |
| 23 | <span style="font-weight:bold">SELECT</span> column_name(s) |
| 24 | <span style="font-weight:bold">FROM</span> table1 |
| 25 | <span style="font-weight:bold">FULL</span> <span style="font-weight:bold">OUTER</span> <span style="font-weight:bold">JOIN</span> table2 <span style="font-weight:bold">ON</span> table1.column_name <span style="color:#ca60ca">=</span> table2.column_name; |
| 26 | |
| 27 | <span style="font-weight:bold">SELECT</span> <span style="color:#ca60ca">*</span> <span style="font-weight:bold">FROM</span> Customers |
| 28 | <span style="font-weight:bold">WHERE</span> City <span style="font-weight:bold">LIKE</span> <span style="color:#bf0303">'[bsp]%'</span>; |
| 29 | |
| 30 | <span style="font-weight:bold">SELECT</span> <span style="color:#644a9b">Count</span>(<span style="color:#ca60ca">*</span>) <span style="font-weight:bold">AS</span> DistinctCountries |
| 31 | <span style="font-weight:bold">FROM</span> (<span style="font-weight:bold">SELECT</span> <span style="font-weight:bold">DISTINCT</span> Country <span style="font-weight:bold">FROM</span> Customers) |
| 32 | <span style="font-weight:bold">GROUP</span> <span style="font-weight:bold">BY</span> Country |
| 33 | <span style="font-weight:bold">HAVING</span> <span style="color:#644a9b">COUNT</span>(CustomerID) <span style="color:#ca60ca">></span> <span style="color:#b08000">5</span> |
| 34 | <span style="font-weight:bold">ORDER</span> <span style="font-weight:bold">BY</span> <span style="color:#644a9b">COUNT</span>(CustomerID) <span style="font-weight:bold">DESC</span>; |
| 35 | |
| 36 | <span style="font-weight:bold">SELECT</span> <span style="color:#bf0303">'Customer'</span> <span style="font-weight:bold">As</span> <span style="font-weight:bold">Type</span>, ContactName, City, Country |
| 37 | <span style="font-weight:bold">FROM</span> Customers |
| 38 | <span style="font-weight:bold">UNION</span> |
| 39 | <span style="font-weight:bold">SELECT</span> <span style="color:#bf0303">'Supplier'</span>, ContactName, City, Country |
| 40 | <span style="font-weight:bold">FROM</span> Suppliers; |
| 41 | |
| 42 | <span style="font-weight:bold">SELECT</span> <span style="color:#644a9b">COUNT</span>(ProductID), <span style="color:#644a9b">AVG</span>(Price) |
| 43 | <span style="font-weight:bold">FROM</span> Products; |
| 44 | |
| 45 | <span style="font-weight:bold">SET</span> lock_timeout <span style="color:#ca60ca">=</span> <span style="color:#b08000">0</span>; |
| 46 | <span style="font-weight:bold">SET</span> client_encoding <span style="color:#ca60ca">=</span> <span style="color:#bf0303">'UTF8'</span>; |
| 47 | <span style="font-weight:bold">SET</span> standard_conforming_strings <span style="color:#ca60ca">=</span> <span style="font-weight:bold">on</span>; |
| 48 | <span style="font-weight:bold">SET</span> check_function_bodies <span style="color:#ca60ca">=</span> <span style="font-weight:bold">false</span>; |
| 49 | <span style="font-weight:bold">SET</span> client_min_messages <span style="color:#ca60ca">=</span> warning; |
| 50 | <span style="font-weight:bold">SET</span> default_tablespace <span style="color:#ca60ca">=</span> <span style="color:#bf0303">''</span>; |
| 51 | |
| 52 | <span style="font-weight:bold">DROP</span> <span style="font-weight:bold">TABLE</span> <span style="font-weight:bold">IF</span> <span style="font-weight:bold">EXISTS</span> employees; |
| 53 | |
| 54 | <span style="font-weight:bold">ALTER</span> <span style="font-weight:bold">TABLE</span> <span style="font-weight:bold">ONLY</span> employees |
| 55 | <span style="font-weight:bold">ADD</span> <span style="font-weight:bold">CONSTRAINT</span> fk_employees_employees <span style="font-weight:bold">FOREIGN</span> <span style="font-weight:bold">KEY</span> (reportsto) <span style="font-weight:bold">REFERENCES</span> employees; |
| 56 | |
| 57 | <span style="font-weight:bold">CREATE</span> <span style="font-weight:bold">VIEW</span> [<span style="font-weight:bold">Current</span> Product <span style="font-weight:bold">List</span>] <span style="font-weight:bold">AS</span> |
| 58 | <span style="font-weight:bold">SELECT</span> ProductID, ProductName |
| 59 | <span style="font-weight:bold">FROM</span> Products |
| 60 | <span style="font-weight:bold">WHERE</span> Discontinued <span style="color:#ca60ca">=</span> <span style="font-weight:bold">No</span>; |
| 61 | |
| 62 | <span style="font-weight:bold">SELECT</span> <span style="color:#ca60ca">*</span> <span style="font-weight:bold">FROM</span> [<span style="font-weight:bold">Current</span> Product <span style="font-weight:bold">List</span>]; |
| 63 | |
| 64 | <span style="font-weight:bold">SELECT</span> <span style="color:#ca60ca">*</span> <span style="font-weight:bold">FROM</span> [<span style="font-weight:bold">Category</span> Sales <span style="font-weight:bold">For</span> <span style="color:#b08000">1997</span>] |
| 65 | <span style="font-weight:bold">WHERE</span> CategoryName <span style="color:#ca60ca">=</span> <span style="color:#bf0303">'Beverages'</span>; |
| 66 | |
| 67 | <span style="font-weight:bold">begin</span> |
| 68 | <span style="font-weight:bold">end</span> |
| 69 | <span style="color:#924c9d">/</span> |
| 70 | <span style="color:#ca60ca">/</span> |
| 71 | <span style="color:#ca60ca">/</span> u |
| 72 | |
| 73 | <span style="color:#898887">/* nested /* comments */ for */</span> PostgreSQL |
| 74 | </pre></body></html> |