2023-10-17 23:36:14 +08:00
|
|
|
[discrete]
|
2023-06-06 00:38:55 +08:00
|
|
|
[[esql-rename]]
|
|
|
|
=== `RENAME`
|
|
|
|
|
2023-06-26 22:31:53 +08:00
|
|
|
Use `RENAME` to rename a column using the following syntax:
|
|
|
|
|
|
|
|
[source,esql]
|
|
|
|
----
|
2023-07-25 18:26:35 +08:00
|
|
|
RENAME <old-name> AS <new-name>
|
2023-06-26 22:31:53 +08:00
|
|
|
----
|
|
|
|
|
|
|
|
For example:
|
2023-06-06 00:38:55 +08:00
|
|
|
|
|
|
|
[source,esql]
|
|
|
|
----
|
|
|
|
include::{esql-specs}/docs.csv-spec[tag=rename]
|
|
|
|
----
|
|
|
|
|
2023-06-26 22:31:53 +08:00
|
|
|
If a column with the new name already exists, it will be replaced by the new
|
|
|
|
column.
|
|
|
|
|
2023-06-06 00:38:55 +08:00
|
|
|
Multiple columns can be renamed with a single `RENAME` command:
|
|
|
|
|
|
|
|
[source,esql]
|
|
|
|
----
|
|
|
|
include::{esql-specs}/docs.csv-spec[tag=renameMultipleColumns]
|
|
|
|
----
|