groonga - オープンソースのカラムストア機能付き全文検索エンジン

7.3.39. truncate

7.3.39.1. 概要

truncate command deletes all records from specified table or all values from specified column.

7.3.39.2. 構文

truncate コマンドの引数は1つだけです:

The required parameter is only target_name:

truncate target_name

バージョン 4.0.9 で追加: target_name parameter can be used since 4.0.9. You need to use table parameter for 4.0.8 or earlier.

For backward compatibility, truncate command accepts table parameter. But it should not be used for newly written code.

7.3.39.3. 使い方

Here is a simple example of truncate command against a table.

実行例:

table_create Users TABLE_PAT_KEY ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Users score COLUMN_SCALAR Int32
# [[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"
#         ],
#         [
#           "score",
#           "Int32"
#         ]
#       ],
#       [
#         1,
#         "Alice",
#         2
#       ],
#       [
#         2,
#         "Bob",
#         0
#       ],
#       [
#         3,
#         "Carlos",
#         -1
#       ]
#     ]
#   ]
# ]
truncate Users
# [[0, 1337566253.89858, 0.000355720520019531], true]
select Users
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         0
#       ],
#       [
#         [
#           "_id",
#           "UInt32"
#         ],
#         [
#           "_key",
#           "ShortText"
#         ],
#         [
#           "score",
#           "Int32"
#         ]
#       ]
#     ]
#   ]
# ]

Here is a simple example of truncate command against a column.

実行例:

table_create Users TABLE_PAT_KEY ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Users score COLUMN_SCALAR Int32
# [[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"
#         ],
#         [
#           "score",
#           "Int32"
#         ]
#       ],
#       [
#         1,
#         "Alice",
#         2
#       ],
#       [
#         2,
#         "Bob",
#         0
#       ],
#       [
#         3,
#         "Carlos",
#         -1
#       ]
#     ]
#   ]
# ]
truncate Users.score
# [[0, 1337566253.89858, 0.000355720520019531], true]
select Users
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         3
#       ],
#       [
#         [
#           "_id",
#           "UInt32"
#         ],
#         [
#           "_key",
#           "ShortText"
#         ],
#         [
#           "score",
#           "Int32"
#         ]
#       ],
#       [
#         1,
#         "Alice",
#         0
#       ],
#       [
#         2,
#         "Bob",
#         0
#       ],
#       [
#         3,
#         "Carlos",
#         0
#       ]
#     ]
#   ]
# ]

7.3.39.4. 引数

このセクションでは truncate の引数について説明します。

7.3.39.4.1. 必須引数

There is required parameter, target_name.

7.3.39.4.1.1. target_name

It specifies the name of table or column.

7.3.39.5. 戻り値

truncate command returns whether truncation is succeeded or not:

[HEADER, SUCCEEDED_OR_NOT]

HEADER

HEADER については 出力形式 を参照してください。

SUCCEEDED_OR_NOT

コマンドの実行が成功するとtrueを返します。失敗するとエラーとしてfalseを返します。

目次

前のトピックへ

7.3.38. tokenizer_list

次のトピックへ

7.4. データ型

このページ