groonga - An open-source fulltext search engine and column store.

8.3.32. truncate

8.3.32.1. Summary

truncate command deletes all records from specified table.

8.3.32.2. Syntax

truncate command takes only one parameter.

The required parameter is only table:

truncate table

8.3.32.3. Usage

Here is a simple example of truncate command.

Execution example:

table_create Users TABLE_PAT_KEY ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
load --table Users
[
{"_key": "Alice",  "score": 2},
{"_key": "Bob",    "score": 0},
{"_key": "Carlos", "score": -1}
]
# [[0, 1337566253.89858, 0.000355720520019531], 3]
select Users
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         3
#       ],
#       [
#         [
#           "_id",
#           "UInt32"
#         ],
#         [
#           "_key",
#           "ShortText"
#         ]
#       ],
#       [
#         1,
#         "Alice"
#       ],
#       [
#         2,
#         "Bob"
#       ],
#       [
#         3,
#         "Carlos"
#       ]
#     ]
#   ]
# ]
truncate Users
# [[0, 1337566253.89858, 0.000355720520019531], true]
select Users
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         0
#       ],
#       [
#         [
#           "_id",
#           "UInt32"
#         ],
#         [
#           "_key",
#           "ShortText"
#         ]
#       ]
#     ]
#   ]
# ]

8.3.32.4. Parameters

This section describes parameters of truncate.

8.3.32.4.1. Required parameter

There is required parameter, table_name.

8.3.32.4.1.1. table_name

It specifies the name of table.

8.3.32.5. Return value

[HEADER, SUCCEEDED_OR_NOT]

HEADER

The format of HEADER is [0, UNIX_TIME_WHEN_COMMAND_IS_STARTED, ELAPSED_TIME]. See Output format about HEADER.

SUCCEEDED_OR_NOT

If command succeeded, it returns true, otherwise it returns false on error.