@@ -10,7 +10,7 @@ Tarantool 2.x series. There are two ways to go through this tutorial:
10
10
* read what we say the results are and take our word for it, or
11
11
* copy and paste each section and see everything work with Tarantool 2.1.
12
12
13
- You'll encounter all the functionality that you'd encounter in an "SQL-101"
13
+ You will encounter all the functionality that you'd encounter in an "SQL-101"
14
14
course.
15
15
16
16
.. _sql_tutorial-starting_up_with_a_first_table_and_selects :
@@ -74,11 +74,15 @@ The result of the ``SELECT`` statement will look like this:
74
74
- - [1, 'B']
75
75
...
76
76
77
+ Reality check: actually the result will include include initial fields
78
+ called "metadata", the names and data types of each column. For all
79
+ SELECT examples we show only the result rows without showing the metadata.
80
+
77
81
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78
82
CREATE TABLE
79
83
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80
84
81
- Here's ``CREATE TABLE `` with more details:
85
+ Here is ``CREATE TABLE `` with more details:
82
86
83
87
* There are multiple columns, with different data types.
84
88
* There is a ``PRIMARY KEY `` (unique and not-null) for two of the columns.
@@ -91,7 +95,7 @@ Here's ``CREATE TABLE`` with more details:
91
95
column4 FLOAT,
92
96
PRIMARY KEY (column1, column2));
93
97
94
- The result will be: "``--- ``" (no error).
98
+ The result will be: "``rowcount: 1 ``" (no error).
95
99
96
100
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97
101
INSERT
@@ -246,7 +250,7 @@ values in ``column4``. However, it is not an error that
246
250
247
251
CREATE UNIQUE INDEX i ON table2 (column4);
248
252
249
- The result will be: "``--- ``" (no error).
253
+ The result will be: "``rowcount: 1 ``" (no error).
250
254
251
255
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
252
256
Create a subset table
@@ -675,7 +679,7 @@ Calling from a host language to make a big table
675
679
--------------------------------------------------------------------------------
676
680
677
681
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
678
- box.sql. execute()
682
+ box.execute()
679
683
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
680
684
681
685
Now we will change the settings so that the
@@ -685,7 +689,7 @@ will exist in Tarantool clients in our next version.)
685
689
686
690
This doesn't mean we have left the SQL world though, because we
687
691
can invoke SQL statements using a Lua function:
688
- ``box.sql. execute(string) ``.
692
+ ``box.execute(string) ``.
689
693
690
694
Here we'll switch languages,
691
695
and ask to select again what's in ``table3 ``.
@@ -694,7 +698,7 @@ These statements must be entered separately.
694
698
.. code-block :: tarantoolsession
695
699
696
700
tarantool> \set language lua
697
- tarantool> box.sql. execute([[SELECT * FROM table3;]]);
701
+ tarantool> box.execute([[SELECT * FROM table3;]]);
698
702
699
703
Showing both the statements and the results:
700
704
@@ -703,7 +707,7 @@ Showing both the statements and the results:
703
707
tarantool> \set language lua
704
708
---
705
709
...
706
- tarantool> box.sql. execute([[SELECT * FROM table3;]]);
710
+ tarantool> box.execute([[SELECT * FROM table3;]]);
707
711
---
708
712
- - [-1000, '']
709
713
- [0, '!!!']
@@ -726,7 +730,7 @@ instructions and wait for about a minute.
726
730
727
731
.. code-block :: lua
728
732
729
- box.sql. execute("CREATE TABLE tester (s1 INT PRIMARY KEY, s2 VARCHAR(10))");
733
+ box.execute("CREATE TABLE tester (s1 INT PRIMARY KEY, s2 VARCHAR(10))");
730
734
731
735
function string_function()
732
736
local random_number
@@ -744,7 +748,7 @@ instructions and wait for about a minute.
744
748
for i = 1,1000000,1 do
745
749
string_value = string_function()
746
750
sql_statement = "INSERT INTO tester VALUES (" .. i .. ",'" .. string_value .. "')"
747
- box.sql. execute(sql_statement)
751
+ box.execute(sql_statement)
748
752
end
749
753
end;
750
754
start_time = os.clock();
@@ -771,8 +775,8 @@ an index, because for ``s2`` we didn't say
771
775
772
776
.. code-block :: lua
773
777
774
- box.sql. execute([[SELECT * FROM tester WHERE s1 = 73446;]]);
775
- box.sql. execute([[SELECT * FROM tester WHERE s2 LIKE 'QFML%';]]);
778
+ box.execute([[SELECT * FROM tester WHERE s1 = 73446;]]);
779
+ box.execute([[SELECT * FROM tester WHERE s2 LIKE 'QFML%';]]);
776
780
777
781
The result is:
778
782
0 commit comments