Skip to content

Commit 8abc8a7

Browse files
authored
Add prerequisites to SQL Beginner's Guide (#4200)
Fixes #4199
1 parent d0a40d4 commit 8abc8a7

File tree

2 files changed

+19
-44
lines changed

2 files changed

+19
-44
lines changed

doc/how-to/sql/sql_beginners_guide.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ The SQL Beginners' Guide is about databases in general, and about the relationsh
99
Tarantool's NoSQL and SQL products.
1010
Most of the matters in the Beginners' Guide will already be familiar to people who have used relational databases before.
1111

12+
.. include:: sql_tutorial.rst
13+
:start-after: sql_prereq_start
14+
:end-before: sql_prereq_end
15+
1216
.. _sql_beginners_sample_table:
1317

1418
Sample table

doc/how-to/sql/sql_tutorial.rst

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ SQL tutorial
66
This tutorial is a demonstration of the support for SQL in Tarantool.
77
It includes the functionality that you'd encounter in an "SQL-101" course.
88

9+
.. sql_prereq_start
10+
911
.. _sql_tutorial-prerequisites:
1012

1113
Prerequisites
@@ -15,63 +17,32 @@ Before starting this tutorial:
1517

1618
#. Install the :ref:`tt CLI <tt-installation>` utility.
1719

18-
#. Create a tt environment in the current directory using the :ref:`tt init <tt-init>` command.
20+
#. Start a Tarantool instance in the interactive mode by running :ref:`tt run -i <tt-run>`:
1921

20-
#. Inside the ``instances.enabled`` directory of the created tt environment, create the ``sql_tutorial`` directory.
22+
.. code-block:: console
2123
22-
#. Inside ``instances.enabled/sql_tutorial``, create the ``instances.yml`` and ``config.yaml`` files:
24+
$ tt run -i
25+
Tarantool 3.0.0-0-g6ba34da7f8
26+
type 'help' for interactive help
27+
tarantool>
2328
24-
* ``instances.yml`` specifies instances to run in the current environment:
29+
#. Initialize the instance and switch the input language to SQL:
2530

26-
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/instance_scope/instances.yml
27-
:language: yaml
28-
:dedent:
31+
.. code-block:: tarantoolsession
2932
30-
* ``config.yaml`` contains basic :ref:`configuration <configuration_file>`:
33+
tarantool> box.cfg{}
34+
tarantool> \set language sql
35+
tarantool> \set delimiter ;
3136
32-
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/instance_scope/config.yaml
33-
:language: yaml
34-
:dedent:
37+
Now you have a running Tarantool instance that accepts SQL input.
3538

36-
Read more: :ref:`Starting instances using the tt utility <configuration_run_instance_tt>`.
39+
.. sql_prereq_end
3740
3841
.. _sql_tutorial-starting_up_with_a_first_table_and_selects:
3942

4043
Create a table and execute SQL statements
4144
-----------------------------------------
4245

43-
Start Tarantool
44-
~~~~~~~~~~~~~~~
45-
46-
After configuration, start a Tarantool instance from the tt environment directory using the following command:
47-
48-
.. code-block:: console
49-
50-
$ tt start sql_tutorial
51-
52-
After that, connect to the instance:
53-
54-
.. code-block:: console
55-
56-
$ tt connect sql_tutorial:instance001
57-
58-
This command opens an interactive Tarantool console.
59-
Now you can start working with the database.
60-
61-
Switch to the SQL language
62-
~~~~~~~~~~~~~~~~~~~~~~~~~~
63-
64-
A feature of the client console program is that you can switch languages and
65-
specify the end-of-statement delimiter.
66-
67-
Run the following commands to set the :ref:`console input <interactive_console_input_output>` language to SQL and use
68-
semicolon as a delimiter:
69-
70-
.. code-block:: tarantoolsession
71-
72-
sql_tutorial:instance001> \set language sql
73-
sql_tutorial:instance001> \set delimiter ;
74-
7546

7647
CREATE, INSERT, UPDATE, SELECT
7748
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)