Merge branch 'docs-v2' into 'main'

docs: add example query

See merge request x433485/minisql!24
This commit is contained in:
Jindřich Moravec 2024-01-28 23:48:24 +01:00
commit ee757c7ca2

View file

@ -70,6 +70,11 @@ To exit the REPL client, enter `exit` or `quit`.
CREATE TABLE <TableName> (<ColumnName> <DataType>, ...);
```
With the demo database, this can be used to create a new table:
```sql
CREATE TABLE games (id UUID PRIMARY KEY, name STRING, year INT, price NUMBER);
```
### `CREATE INDEX`
- Indexing is not supported for the `NUMBER` data type
@ -77,6 +82,11 @@ CREATE TABLE <TableName> (<ColumnName> <DataType>, ...);
CREATE INDEX <IndexName> ON <TableName> (<ColumnName>);
```
With the demo database, this can be used to create a new index:
```sql
CREATE INDEX CarsYear ON cars (year);
```
### `SELECT`
- `WHERE` clause is optional and only equality is supported
- All columns can be selected with `*`
@ -85,12 +95,23 @@ CREATE INDEX <IndexName> ON <TableName> (<ColumnName>);
SELECT <ColumnName>, ... FROM <TableName> [WHERE <ColumnName> = <Value>];
```
With the demo database, this can be used to select all cars with year 2001:
```sql
SELECT * FROM cars WHERE year = 2001;
```
### `INSERT`
```sql
INSERT INTO <TableName> (<ColumnName>, ...) VALUES (<Value>, ...);
```
With the demo database, this can be used to insert a new user:
```sql
INSERT INTO users (id, name, surname, email) VALUES (u12345, "John", "Doe", "johhny.trucker@seznam.cz");
```
### `DELETE`
- `WHERE` clause is optional and only equality is supported
@ -98,6 +119,11 @@ INSERT INTO <TableName> (<ColumnName>, ...) VALUES (<Value>, ...);
DELETE FROM <TableName> [WHERE <ColumnName> = <Value>];
```
With the demo database, this can be used to delete all users with name Christina:
```sql
DELETE FROM users WHERE name = "Christina";
```
## Data Types
- `UUID` - special integer prefixed with `u`, e.g. `u12345`
- `STRING` - string enclosed in double quotes, e.g. `"Hello World"`