1-- comment
2
3CREATE TABLE stuff COLUMNS(col1 INT, col2 Varchar);
4SELECT * FROM stuff WHERE id = 'string';
5select * from stuff where id < 0.42;
6Select col1, col2 From stuff Where stuff.col1 IS NOT NuLL;
7
8CREATE TABLE Persons (
9    ID int NOT NULL AUTO_INCREMENT,
10    LastName varchar(255) NOT NULL,
11    FirstName varchar(255),
12    Age int,
13    PRIMARY KEY (ID)
14    CONSTRAINT CHK_Person CHECK (Age>=18 AND City='Sandnes')
15);
16
17SELECT column_name(s)
18FROM table1
19FULL OUTER JOIN table2 ON table1.column_name = table2.column_name;
20
21SELECT * FROM Customers
22WHERE City LIKE '[bsp]%';
23
24SELECT Count(*) AS DistinctCountries
25FROM (SELECT DISTINCT Country FROM Customers)
26GROUP BY Country
27HAVING COUNT(CustomerID) > 5
28ORDER BY COUNT(CustomerID) DESC;
29
30SELECT 'Customer' As Type, ContactName, City, Country
31FROM Customers
32UNION
33SELECT 'Supplier', ContactName, City, Country
34FROM Suppliers;
35
36SELECT COUNT(ProductID), AVG(Price)
37FROM Products;
38
39SET lock_timeout = 0;
40SET client_encoding = 'UTF8';
41SET standard_conforming_strings = on;
42SET check_function_bodies = false;
43SET client_min_messages = warning;
44SET default_tablespace = '';
45
46DROP TABLE IF EXISTS employees;
47
48ALTER TABLE ONLY employees
49    ADD CONSTRAINT fk_employees_employees FOREIGN KEY (reportsto) REFERENCES employees;
50
51CREATE VIEW [Current Product List] AS
52SELECT ProductID, ProductName
53FROM Products
54WHERE Discontinued = No;
55
56SELECT * FROM [Current Product List];
57
58SELECT * FROM [Category Sales For 1997]
59WHERE CategoryName = 'Beverages';
60
61begin
62end
63/
64 /
65/ u
66