diff --git a/README.md b/README.md index 6eb5011..931ee1f 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ To use the SQL Parser in your own code, you only need to include `SQLParser.h` a ### Documentation +* [Working Syntax Examples](docs/sytax.md) * [Developer Documentation](docs/documentation.md) * [Integration in Hyrise](docs/integration.md) * [Known Issues](docs/issues.md) diff --git a/docs/syntax.md b/docs/syntax.md new file mode 100644 index 0000000..be1d4d0 --- /dev/null +++ b/docs/syntax.md @@ -0,0 +1,44 @@ +Syntax Examples +=============== + +This page contains some samples of SQL statements that can be executed in Hyrise. + + +**Create Tables** +```sql +CREATE TABLE IF NOT EXISTS students FROM TBL FILE 'test/students.tbl'; +CREATE TABLE test (v1 INTEGER, v2 INTEGER, v3 INTEGER); +``` + + +**Select with Join** +```sql +SELECT name, city, * FROM students AS t1 JOIN students AS t2 ON t1.city = t2.city WHERE t1.grade < 2.0 AND t2.grade > 2.0 AND t1.city = 'Frohnau' ORDER BY t1.grade DESC; +``` + + +**Group By** +```sql +SELECT city, AVG(grade) AS average, MIN(grade) AS best, MAX(grade) AS worst FROM students GROUP BY city; +``` + + +**Update and Delete** +```sql +UPDATE students SET name='Max Mustermann' WHERE name = 'Ralf Stiebitz'; +DELETE FROM students WHERE name = 'Max Mustermann'; +``` + + +**Prepare and Execute** +```sql +PREPARE batch_insert { + INSERT INTO test VALUES (?, 0, 0); + INSERT INTO test VALUES (?, 0, 0); + INSERT INTO test VALUES (?, 0, 0); + INSERT INTO test VALUES (?, 0, 0); + INSERT INTO test VALUES (?, 0, 0); +}; + +EXECUTE insert_test(1, 2, 3, 4 ,5); +```