Debian Codegraph @

doc/source/reference/commands/truncate.rst

raw
1 .. -*- rst -*-
2
3 ``truncate``
4 ============
5
6 Summary
7 -------
8
9 ``truncate`` command deletes all records from specified table or all
10 values from specified column.
11
12 Syntax
13 ------
14
15 This command takes only one required parameter::
16
17 truncate target_name
18
19 .. versionadded:: 4.0.9
20
21 ``target_name`` parameter can be used since 4.0.9. You need to use
22 ``table`` parameter for 4.0.8 or earlier.
23
24 For backward compatibility, ``truncate`` command accepts ``table``
25 parameter. But it should not be used for newly written code.
26
27 Usage
28 -----
29
30 Here is a simple example of ``truncate`` command against a table.
31
32 .. groonga-command
33 .. database: commands_truncate_table
34 .. include:: ../../example/reference/commands/truncate/truncate_table.log
35 .. table_create Users TABLE_PAT_KEY ShortText
36 .. column_create Users score COLUMN_SCALAR Int32
37 .. load --table Users
38 .. [
39 .. {"_key": "Alice", "score": 2},
40 .. {"_key": "Bob", "score": 0},
41 .. {"_key": "Carlos", "score": -1}
42 .. ]
43 .. select Users
44 .. truncate Users
45 .. select Users
46
47 Here is a simple example of ``truncate`` command against a column.
48
49 .. groonga-command
50 .. database: commands_truncate_column
51 .. include:: ../../example/reference/commands/truncate/truncate_column.log
52 .. table_create Users TABLE_PAT_KEY ShortText
53 .. column_create Users score COLUMN_SCALAR Int32
54 .. load --table Users
55 .. [
56 .. {"_key": "Alice", "score": 2},
57 .. {"_key": "Bob", "score": 0},
58 .. {"_key": "Carlos", "score": -1}
59 .. ]
60 .. select Users
61 .. truncate Users.score
62 .. select Users
63
64 Parameters
65 ----------
66
67 This section describes parameters of ``truncate``.
68
69 Required parameters
70 ^^^^^^^^^^^^^^^^^^^
71
72 There is required parameter, ``target_name``.
73
74 ``target_name``
75 """""""""""""""
76
77 Specifies the name of table or column.
78
79 Return value
80 ------------
81
82 ``truncate`` command returns whether truncation is succeeded or not::
83
84 [HEADER, SUCCEEDED_OR_NOT]
85
86 ``HEADER``
87
88 See :doc:`/reference/command/output_format` about ``HEADER``.
89
90 ``SUCCEEDED_OR_NOT``
91
92 If command succeeded, it returns true, otherwise it returns false on error.
93