<commit_before>.. -*- rst -*-

.. highlightlang:: none

``truncate``
============

Summary
-------

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

Syntax
------

``truncate`` command takes only one parameter.

The required parameter is only ``target_name``::

  truncate target_name

.. note::

   ``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.

Usage
-----

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

.. groonga-command
.. database: commands_truncate_table
.. include:: ../../example/reference/commands/truncate/truncate_table.log
.. table_create Users TABLE_PAT_KEY ShortText
.. column_create Users score COLUMN_SCALAR Int32
.. load --table Users
.. [
.. {"_key": "Alice",  "score": 2},
.. {"_key": "Bob",    "score": 0},
.. {"_key": "Carlos", "score": -1}
.. ]
.. select Users
.. truncate Users
.. select Users

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

.. groonga-command<commit_msg>doc truncate: use versionadded directive<commit_after>.. -*- rst -*-

.. highlightlang:: none

``truncate``
============

Summary
-------

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

Syntax
------

``truncate`` command takes only one parameter.

The required parameter is only ``target_name``::

  truncate target_name

.. versionadded:: 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.

Usage
-----

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

.. groonga-command
.. database: commands_truncate_table
.. include:: ../../example/reference/commands/truncate/truncate_table.log
.. table_create Users TABLE_PAT_KEY ShortText
.. column_create Users score COLUMN_SCALAR Int32
.. load --table Users
.. [
.. {"_key": "Alice",  "score": 2},
.. {"_key": "Bob",    "score": 0},
.. {"_key": "Carlos", "score": -1}
.. ]
.. select Users
.. truncate Users
.. select Users

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

.. groonga-command
{'fraction_non_alphanumeric': 0.15819909128459314, 'fraction_numerical': 0.010326311441553077, 'mean_word_length': 3.356115107913669, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3619286', 'n_tokens_mistral': 756, 'n_tokens_neox': 713, 'n_words': 264}