Debian Codegraph @

doc/source/reference/commands/table_rename.rst

raw
1 .. -*- rst -*-
2
3 .. groonga-command
4 .. database: commands_table_rename
5
6 ``table_rename``
7 =================
8
9 Summary
10 -------
11
12 ``table_rename`` command renames a table.
13
14 It is a light operation. It just changes a relationship between name
15 and the table object. It doesn't copy table and its column values.
16
17 It is a dangerous operation. You must stop all operations including
18 read operations while you run ``table_rename``. If the following case
19 is occurred, Groonga process may be crashed:
20
21 * Starts an operation (like ``select``) that accesses the table to
22 be renamed by the current table name. The current table name is
23 called as ``the old table name`` in the below because the table
24 name is renamed.
25 * Runs ``table_rename``. The ``select`` is still running.
26 * The ``select`` accesses the table to be renamed by the old table
27 name. But the ``select`` can't find the table by the old name
28 because the table has been renamed to the new table name. It may
29 crash the Groonga process.
30
31 Syntax
32 ------
33
34 This command takes two parameters.
35
36 All parameters are required::
37
38 table_rename name new_name
39
40 Usage
41 -----
42
43 Here is a simple example of ``table_rename`` command.
44
45 .. groonga-command
46 .. include:: ../../example/reference/commands/table_rename/usage.log
47 .. table_create Users TABLE_PAT_KEY ShortText
48 .. column_create Users score COLUMN_SCALAR Int32
49 .. load --table Users
50 .. [
51 .. {"_key": "Alice", "score": 2},
52 .. {"_key": "Bob", "score": 0},
53 .. {"_key": "Carlos", "score": -1}
54 .. ]
55 .. table_rename Users Players
56 .. table_list
57 .. select Players
58
59 Parameters
60 ----------
61
62 This section describes parameters of ``table_rename``.
63
64 Required parameters
65 ^^^^^^^^^^^^^^^^^^^
66
67 All parameters are required.
68
69 ``name``
70 """"""""
71
72 Specifies the table name to be renamed.
73
74 ``new_name``
75 """"""""""""
76
77 Specifies the new table name.
78
79 Return value
80 ------------
81
82 The command returns ``true`` as body on success such as::
83
84 [HEADER, true]
85
86 If the command fails, error details are in ``HEADER``.
87
88 See :doc:`/reference/command/output_format` for ``HEADER``.