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