2017-08-14 15:13:56 +02:00
|
|
|
# This file contains a list of strings that are NOT valid SQL queries.
|
|
|
|
# Each line contains a single SQL query.
|
2014-11-12 10:43:10 +01:00
|
|
|
# SELECT statement
|
|
|
|
SELECT * FROM orders;
|
|
|
|
SELECT a FROM foo WHERE a > 12 OR b > 3 AND NOT c LIMIT 10
|
|
|
|
SELECT col1 AS myname, col2, 'test' FROM "table", foo AS t WHERE age > 12 AND zipcode = 12345 GROUP BY col1;
|
|
|
|
SELECT * from "table" JOIN table2 ON a = b WHERE (b OR NOT a) AND a = 12.5
|
|
|
|
(SELECT a FROM foo WHERE a > 12 OR b > 3 AND c NOT LIKE 's%' LIMIT 10);
|
2014-12-15 15:01:01 +01:00
|
|
|
SELECT * FROM "table" LIMIT 10 OFFSET 10; SELECT * FROM second;
|
2014-11-26 00:26:20 +01:00
|
|
|
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY col1;
|
2017-03-06 18:30:35 +01:00
|
|
|
SELECT * FROM (SELECT * FROM t1);
|
|
|
|
SELECT * FROM t1 UNION (SELECT * FROM t2 UNION SELECT * FROM t3) ORDER BY col1;
|
2017-03-07 02:30:44 +01:00
|
|
|
SELECT TOP 10 * FROM t1 ORDER BY col1, col2;
|
2017-03-07 02:49:29 +01:00
|
|
|
SELECT a, MAX(b), MAX(c, d), CUSTOM(q, UP(r)) AS f FROM t1;
|
2017-03-07 13:49:56 +01:00
|
|
|
SELECT * FROM t WHERE a BETWEEN 1 and c;
|
2017-05-29 16:22:13 +02:00
|
|
|
SELECT * FROM t WHERE a = ? AND b = ?;
|
2017-04-21 22:03:12 +02:00
|
|
|
SELECT City.name, Product.category, SUM(price) FROM fact INNER JOIN City ON fact.city_id = City.id INNER JOIN Product ON fact.product_id = Product.id GROUP BY City.name, Product.category;
|
2014-11-17 22:13:11 +01:00
|
|
|
# JOIN
|
|
|
|
SELECT t1.a, t1.b, t2.c FROM "table" AS t1 JOIN (SELECT * FROM foo JOIN bar ON foo.id = bar.id) t2 ON t1.a = t2.b WHERE (t1.b OR NOT t1.a) AND t2.c = 12.5
|
2014-11-18 16:38:31 +01:00
|
|
|
SELECT * FROM t1 JOIN t2 ON c1 = c2;
|
2014-12-18 12:11:26 +01:00
|
|
|
SELECT a, SUM(b) FROM t2 GROUP BY a HAVING SUM(b) > 100;
|
2014-11-12 10:43:10 +01:00
|
|
|
# CREATE statement
|
|
|
|
CREATE TABLE "table" FROM TBL FILE 'students.tbl'
|
2014-11-17 02:18:31 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS "table" FROM TBL FILE 'students.tbl'
|
2014-11-26 14:43:22 +01:00
|
|
|
CREATE TABLE students (name TEXT, student_number INTEGER, city TEXT, grade DOUBLE)
|
2014-11-12 10:43:10 +01:00
|
|
|
# Multiple statements
|
2014-11-26 00:26:20 +01:00
|
|
|
CREATE TABLE "table" FROM TBL FILE 'students.tbl'; SELECT * FROM "table";
|
|
|
|
# INSERT
|
|
|
|
INSERT INTO test_table VALUES (1, 2, 'test');
|
|
|
|
INSERT INTO test_table (id, value, name) VALUES (1, 2, 'test');
|
2014-11-26 14:43:22 +01:00
|
|
|
INSERT INTO test_table SELECT * FROM students;
|
|
|
|
# DELETE
|
|
|
|
DELETE FROM students WHERE grade > 3.0
|
|
|
|
DELETE FROM students
|
2014-12-02 01:27:02 +01:00
|
|
|
TRUNCATE students
|
|
|
|
# UPDATE
|
|
|
|
UPDATE students SET grade = 1.3 WHERE name = 'Max Mustermann';
|
|
|
|
UPDATE students SET grade = 1.3, name='Felix Fürstenberg' WHERE name = 'Max Mustermann';
|
2014-12-03 16:53:49 +01:00
|
|
|
UPDATE students SET grade = 1.0;
|
|
|
|
# DROP
|
2014-12-15 14:43:42 +01:00
|
|
|
DROP TABLE students;
|
2017-09-29 11:15:18 +02:00
|
|
|
DROP TABLE IF EXISTS students;
|
|
|
|
DROP VIEW IF EXISTS students;
|
2014-12-15 14:43:42 +01:00
|
|
|
# PREPARE
|
2017-05-29 16:22:13 +02:00
|
|
|
PREPARE prep_inst FROM 'INSERT INTO test VALUES (?, ?, ?)';
|
|
|
|
PREPARE prep2 FROM 'INSERT INTO test VALUES (?, 0, 0); INSERT INTO test VALUES (0, ?, 0); INSERT INTO test VALUES (0, 0, ?);';
|
2015-01-06 19:20:52 +01:00
|
|
|
EXECUTE prep_inst(1, 2, 3);
|
2015-01-07 13:42:11 +01:00
|
|
|
EXECUTE prep;
|
2017-02-08 04:55:45 +01:00
|
|
|
DEALLOCATE PREPARE prep;
|
2017-06-06 03:49:41 +02:00
|
|
|
# HINTS
|
|
|
|
SELECT * FROM test WITH HINT(NO_CACHE);
|
|
|
|
SELECT * FROM test WITH HINT(NO_CACHE, NO_SAMPLING);
|
2017-08-23 23:09:02 +02:00
|
|
|
SELECT * FROM test WITH HINT(NO_CACHE, SAMPLE_RATE(0.1), OMW(1.0, 'test'));
|
|
|
|
SHOW TABLES;
|
|
|
|
SHOW COLUMNS students;
|