Merge branch 'docs-v2' into 'main'
docs: add example query See merge request x433485/minisql!24
This commit is contained in:
commit
ee757c7ca2
1 changed files with 26 additions and 0 deletions
26
README.md
26
README.md
|
|
@ -70,6 +70,11 @@ To exit the REPL client, enter `exit` or `quit`.
|
||||||
CREATE TABLE <TableName> (<ColumnName> <DataType>, ...);
|
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`
|
### `CREATE INDEX`
|
||||||
- Indexing is not supported for the `NUMBER` data type
|
- Indexing is not supported for the `NUMBER` data type
|
||||||
|
|
||||||
|
|
@ -77,6 +82,11 @@ CREATE TABLE <TableName> (<ColumnName> <DataType>, ...);
|
||||||
CREATE INDEX <IndexName> ON <TableName> (<ColumnName>);
|
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`
|
### `SELECT`
|
||||||
- `WHERE` clause is optional and only equality is supported
|
- `WHERE` clause is optional and only equality is supported
|
||||||
- All columns can be selected with `*`
|
- All columns can be selected with `*`
|
||||||
|
|
@ -85,12 +95,23 @@ CREATE INDEX <IndexName> ON <TableName> (<ColumnName>);
|
||||||
SELECT <ColumnName>, ... FROM <TableName> [WHERE <ColumnName> = <Value>];
|
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`
|
### `INSERT`
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
INSERT INTO <TableName> (<ColumnName>, ...) VALUES (<Value>, ...);
|
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`
|
### `DELETE`
|
||||||
- `WHERE` clause is optional and only equality is supported
|
- `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>];
|
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
|
## Data Types
|
||||||
- `UUID` - special integer prefixed with `u`, e.g. `u12345`
|
- `UUID` - special integer prefixed with `u`, e.g. `u12345`
|
||||||
- `STRING` - string enclosed in double quotes, e.g. `"Hello World"`
|
- `STRING` - string enclosed in double quotes, e.g. `"Hello World"`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue