column_rename command renames specified column name of table.
column_rename command takes two parameters.
The required parameter is table and column_name:
column_rename table column
Here is a simple example of column_rename command.
Execution example:
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]
column_rename Users score point
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_list Users
# [
# [
# 0,
# 1337566253.89858,
# 0.000355720520019531
# ],
# [
# [
# [
# "id",
# "UInt32"
# ],
# [
# "name",
# "ShortText"
# ],
# [
# "path",
# "ShortText"
# ],
# [
# "type",
# "ShortText"
# ],
# [
# "flags",
# "ShortText"
# ],
# [
# "domain",
# "ShortText"
# ],
# [
# "range",
# "ShortText"
# ],
# [
# "source",
# "ShortText"
# ]
# ],
# [
# 256,
# "_key",
# "",
# "",
# "COLUMN_SCALAR",
# "Users",
# "ShortText",
# []
# ],
# [
# 257,
# "point",
# "/tmp/groonga-databases/commands_column_rename.0000101",
# "fix",
# "COLUMN_SCALAR|PERSISTENT",
# "Users",
# "Int32",
# []
# ]
# ]
# ]
select Users
# [
# [
# 0,
# 1337566253.89858,
# 0.000355720520019531
# ],
# [
# [
# [
# 3
# ],
# [
# [
# "_id",
# "UInt32"
# ],
# [
# "_key",
# "ShortText"
# ],
# [
# "point",
# "Int32"
# ]
# ],
# [
# 1,
# "Alice",
# 2
# ],
# [
# 2,
# "Bob",
# 0
# ],
# [
# 3,
# "Carlos",
# -1
# ]
# ]
# ]
# ]
This section describes parameters of column_rename.
[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.