@@ -32,11 +32,11 @@ we prefer to pick out specific items by their contents. In that spirit, this is
32
32
33
33
.. code-block :: none
34
34
35
- modules
35
+ MODULES
36
36
37
37
+-----------------+------+---------------------+
38
- | name | size | purpose |
39
- +-----------------| ------| ---------------------|
38
+ | NAME | SIZE | PURPOSE |
39
+ +-----------------+ ------+ ---------------------+
40
40
| box | 1432 | Database Management |
41
41
| clock | 188 | Seconds |
42
42
| crypto | 4 | Cryptography |
@@ -165,8 +165,8 @@ A primary-key column automatically has a UNIQUE index.
165
165
166
166
data domain -- if a column is defined as having data type INTEGER, it is illegal to put a non-number into it.
167
167
More generally, if a value doesn't correspond to the data type of the definition, it is illegal.
168
- However, some database management systems (DBMSs) are very forgiving and will try to
169
- make allowances for bad values rather than reject them; Tarantool is one of those DBMSs.
168
+ Some database management systems (DBMSs) are very forgiving and will try to
169
+ make allowances for bad values rather than reject them; Tarantool is a bit more strict than those DBMSs.
170
170
171
171
Now, here are other types of constraints ...
172
172
@@ -216,7 +216,7 @@ By default searches in Tarantool's SQL use a binary collation. This will work:
216
216
``INSERT INTO submodules `` |br |
217
217
|nbsp | |nbsp | ``VALUES ('space', 'box', 10000, 'insert etc.'); ``
218
218
219
- Now try to delete the new row from the modules table:
219
+ Now try to delete the corresponding row from the modules table:
220
220
221
221
``DELETE FROM modules WHERE name = 'box'; ``
222
222
@@ -352,9 +352,9 @@ but displayed as a table the result will look like
352
352
.. code-block :: none
353
353
354
354
+----------------+------------------------+
355
- | double_size | concatenated_literals |
355
+ | DOUBLE_SIZE | CONCATENATED_LITERALS |
356
356
+----------------+------------------------+
357
- | 8 | XY |
357
+ | 8 | XY |
358
358
+----------------+------------------------+
359
359
360
360
**Selecting with a select list with asterisk **
@@ -411,7 +411,7 @@ The result will look like this:
411
411
.. code-block :: none
412
412
413
413
+-------------------+------------------------+--------------------+
414
- | submodules_name | modules_purpose | submodules_purpose |
414
+ | SUBMODULES_NAME | MODULES_PURPOSE | SUBMODULES_PURPOSE |
415
415
+-------------------+------------------------+--------------------+
416
416
| space | Database Management | insert etc. |
417
417
+-------------------+------------------------+--------------------+
@@ -437,11 +437,11 @@ That is legal. Usually it is not what you want, but it is a learning aid. The re
437
437
438
438
{ columns from modules table } { columns from submodules table }
439
439
+--------+------+---------------------+-------+-------------+-------+-------------+
440
- | name | size | purpose | name | module_name | size | purpose |
440
+ | NAME | SIZE | PURPOSE | NAME | MODULE_NAME | SIZE | PURPOSE |
441
441
+--------+------+---------------------+-------+-------------+-------+-------------+
442
442
| box | 1432 | Database Management | space | box | 10000 | insert etc. |
443
- | clock | 188 | Seconds | space | box | 10000 | insert etc. |
444
- | crypto | 4 | Cryptography | space | box | 10000 | insert etc. |
443
+ | clock | 188 | Seconds | space | box | 10000 | insert etc. |
444
+ | crypto | 4 | Cryptography | space | box | 10000 | insert etc. |
445
445
+--------+------+---------------------+-------+-------------+-------+-------------+
446
446
447
447
It is not an error. The meaning of this type of join is "combine every row in table-1 with every row in table-2".
@@ -469,12 +469,12 @@ The result will be:
469
469
.. code-block :: none
470
470
471
471
+----------+-----------+------------+--------+---------+-------+-------------+
472
- | modules_ | modules_ | modules_ | name | module_ | size | purpose |
473
- | name | size | purpose | | name | | |
474
- +----------+-----------+--------- --+--------+---------+-------+-------------|
475
- | box | 1432 | Database | space | box | 10000 | insert etc. |
472
+ | MODULES_ | MODULES_ | MODULES_ | NAME | MODULE_ | SIZE | PURPOSE |
473
+ | NAME | SIZE | PURPOSE | | NAME | | |
474
+ +----------+-----------+--------- --+--------+---------+-------+-------------+
475
+ | box | 1432 | Database | space | box | 10000 | insert etc. |
476
476
| | | Management | | | | |
477
- +----------+-----------+------------+--------+---------+-------+-------------|
477
+ +----------+-----------+------------+--------+---------+-------+-------------+
478
478
479
479
In other words, you can specify a Cartesian join in the FROM clause,
480
480
then you can filter out the irrelevant rows in the WHERE clause,
@@ -556,11 +556,11 @@ which returns:
556
556
557
557
{ columns from modules table } { columns from submodules table }
558
558
+--------+------+---------------------+-------+-------------+-------+-------------+
559
- | name | size | purpose | name | module_name | size | purpose |
559
+ | NAME | SIZE | PURPOSE | NAME | MODULE_NAME | SIZE | PURPOSE |
560
560
+--------+------+---------------------+-------+-------------+-------+-------------+
561
561
| box | 1432 | Database Management | space | box | 10000 | insert etc. |
562
- | clock | 188 | Seconds | NULL | NULL | NULL | NULL |
563
- | crypto | 4 | Cryptography | NULL | NULL | NULL | NULL |
562
+ | clock | 188 | Seconds | NULL | NULL | NULL | NULL |
563
+ | crypto | 4 | Cryptography | NULL | NULL | NULL | NULL |
564
564
+--------+------+---------------------+-------+-------------+-------+-------------+
565
565
566
566
Thus, for the submodules of the clock module and the submodules of the crypto
@@ -585,11 +585,11 @@ Remember that our modules table looks like this:
585
585
586
586
.. code-block :: none
587
587
588
- modules
588
+ MODULES
589
589
590
590
+-----------------+------+---------------------+
591
- | name | size | purpose |
592
- +-----------------| ------| ---------------------|
591
+ | NAME | SIZE | PURPOSE |
592
+ +-----------------+ ------+ ---------------------+
593
593
| box | 1432 | Database Management |
594
594
| clock | 188 | Seconds |
595
595
| crypto | 4 | Cryptography |
@@ -598,7 +598,7 @@ Remember that our modules table looks like this:
598
598
599
599
Suppose that we do not want to know all the individual size values,
600
600
we just want to know about their aggregation, that is, take the attributes of the collection.
601
- SQL allows five aggregation functions: AVG (average), SUM, MIN (minimum), MAX (maximum), and COUNT.
601
+ SQL allows aggregation functions including : AVG (average), SUM, MIN (minimum), MAX (maximum), and COUNT.
602
602
For example
603
603
604
604
``SELECT AVG(size), SUM(size), MIN(size), MAX(size), COUNT(size) FROM modules; ``
@@ -607,11 +607,11 @@ The result will look like this:
607
607
608
608
.. code-block :: none
609
609
610
- +-------------- +-----------+-----------+-----------+-----------+
611
- | COLUMN_1 | COLUMN_2 | COLUMN_3 | COLUMN_4 | COLUMN_5 |
612
- +-------------- +-----------+-----------+-----------+-----------|
613
- | 5.413333E+02 | 1624 | 4 | 1432 | 3 |
614
- +-------------- +-----------+-----------+-----------+-----------+
610
+ +-----------+-----------+-----------+-----------+-----------+
611
+ | COLUMN_1 | COLUMN_2 | COLUMN_3 | COLUMN_4 | COLUMN_5 |
612
+ +-----------+-----------+-----------+-----------+-----------|
613
+ | 541 | 1624 | 4 | 1432 | 3 |
614
+ +-----------+-----------+-----------+-----------+-----------+
615
615
616
616
Suppose that we want aggregations, but aggregations of rows that have some common characteristic.
617
617
Supposing further, we want to divide the rows into two groups, the ones whose names
@@ -630,10 +630,10 @@ The result will look like this:
630
630
631
631
+------------+--------------+-----------+-----------+-----------+-------------+
632
632
| COLUMN_1 | COLUMN_2 | COLUMN_3 | COLUMN_4 | COLUMN_5 | COLUMN_6 |
633
- +------------+--------------+-----------+-----------+-----------| -------------|
633
+ +------------+--------------+-----------+-----------+-----------+ -------------+
634
634
| b | 1432 | 1432 | 1432 | 1432 | 1 |
635
635
| c | 96 | 192 | 4 | 188 | 2 |
636
- +------------+--------------+-----------+-----------+-----------| -------------+
636
+ +------------+--------------+-----------+-----------+-----------+ -------------+
637
637
638
638
639
639
**Select with common table expression **
0 commit comments