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

- 日本語

# 7.3.42. `object_remove`

## 7.3.42.1. Summary

New in version 6.0.0.

`object_remove` removes an object. You can remove any object including table, column, command and so on. Normally, you should use specific remove command such as table_remove and column_remove.

`object_remove` is danger because you can remove any object. You should use `object_remove` carefully.

`object_remove` has "force mode". You can remove a broken object by "force mode". "Force mode" is useful to resolve problems reported by grndb.

## 7.3.42.2. Syntax

This command takes two parameters:

    object_remove name
                  [force=no]

## 7.3.42.3. Usage

You can remove an object in the database specified by `name`:

Execution example:

    object_remove Users
    # [
    #   [
    #     -22,
    #     1337566253.89858,
    #     0.000355720520019531,
    #     "[object][remove] target object doesn't exist: <Users>",
    #     [
    #       [
    #         "command_object_remove",
    #         "proc_object.c",
    #         121
    #       ]
    #     ]
    #   ],
    #   false
    # ]
    table_create Users TABLE_HASH_KEY ShortText
    # [[0, 1337566253.89858, 0.000355720520019531], true]
    object_remove Users
    # [[0, 1337566253.89858, 0.000355720520019531], true]

The `object_remove Users` returns `false` before you create `Users` table.

The `object_remove Users` returns `true` after you create `Users` table.

You can't remove a broken object by default:

Execution example:

    table_create Users TABLE_HASH_KEY ShortText
    # [[0, 1337566253.89858, 0.000355720520019531], true]
    thread_limit 1
    # [[0, 1337566253.89858, 0.000355720520019531], 1]
    database_unmap
    # [[0, 1337566253.89858, 0.000355720520019531], true]
    echo "BROKEN" > ${DB_PATH}.0000100
    object_remove Users
    # [
    #   [
    #     -22,
    #     1337566253.89858,
    #     0.000355720520019531,
    #     "[object][remove] failed to open the target object: <Users>",
    #     [
    #       [
    #         "command_object_remove",
    #         "proc_object.c",
    #         116
    #       ]
    #     ]
    #   ],
    #   false
    # ]
    object_exist Users
    # [[0, 1337566253.89858, 0.000355720520019531], true]

You can remove a broken object by `--force yes`:

Execution example:

    object_remove Users --force yes
    # [
    #   [
    #     -65,
    #     1337566253.89858,
    #     0.000355720520019531,
    #     "[io][open] file size is too small: <7>(required: >= 64): </tmp/groonga-databases/commands_object_remove.0000100>",
    #     [
    #       [
    #         "grn_io_open",
    #         "io.c",
    #         565
    #       ]
    #     ]
    #   ],
    #   false
    # ]
    object_exist Users
    # [[0, 1337566253.89858, 0.000355720520019531], false]

`--force yes` means you enable "force mode". You can remove a broken object in "force mode".

## 7.3.42.4. Parameters

This section describes all parameters.

### 7.3.42.4.1. Required parameters

There is only one required parameter.

#### 7.3.42.4.1.1. `name`

Specifies the object name to be removed.

If you want to remove a column, use `TABLE_NAME.COLUMN_NAME` format like the following:

Execution example:

    table_create Logs TABLE_NO_KEY
    # [[0, 1337566253.89858, 0.000355720520019531], true]
    column_create Logs timestamp COLUMN_SCALAR Time
    # [[0, 1337566253.89858, 0.000355720520019531], true]
    object_remove Logs.timestamp
    # [[0, 1337566253.89858, 0.000355720520019531], true]

`Logs` is table name and `timestamp` is column name in `Logs.timestamp`.

### 7.3.42.4.2. Optional parameters

There is one optional parameter.

#### 7.3.42.4.2.1. `force`

Specifies whether removing the object in "force mode".

You can't remove a broken object by default. But you can remove a broken object in "force mode".

`force` value must be `yes` or `no`. `yes` means that "force mode" is enabled. `no` means that "force mode" is disabled.

The default value is `no`. It means that "force mode" is disabled by default.

## 7.3.42.5. Return value

The command returns `true` as body when the command removed the specified object without any error. For example:

    [HEADER, true]

The command returns `false` as body when the command gets any errors. For example:

    [HEADER, false]

See Output format for `HEADER`.

Note that `false` doesn't mean that "the command can't remove the object". If you enable "force mode", the command removes the object even if the object is broken. In the case, the object is removed and `false` is returned as body.