12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- [discrete]
- [[esql-rename]]
- === `RENAME`
- The `RENAME` processing command renames one or more columns.
- **Syntax**
- [source,esql]
- ----
- RENAME old_name1 AS new_name1[, ..., old_nameN AS new_nameN]
- ----
- The following syntax is also supported:
- [source,esql]
- ----
- RENAME new_name1 = old_name1[, ..., new_nameN = old_nameN]
- ----
- TIP: Both syntax options can be used interchangeably but we recommend sticking to one for consistency and readability.
- *Parameters*
- `old_nameX`::
- The name of a column you want to rename.
- `new_nameX`::
- The new name of the column. If it conflicts with an existing column name,
- the existing column is dropped. If multiple columns are renamed to the same
- name, all but the rightmost column with the same new name are dropped.
- *Description*
- The `RENAME` processing command renames one or more columns. If a column with
- the new name already exists, it will be replaced by the new column.
- A `RENAME` with multiple column renames is equivalent to multiple sequential `RENAME` commands.
- *Examples*
- [source,esql]
- ----
- include::{esql-specs}/docs.csv-spec[tag=rename]
- ----
- Multiple columns can be renamed with a single `RENAME` command:
- [source,esql]
- ----
- include::{esql-specs}/docs.csv-spec[tag=renameMultipleColumns]
- ----
- With multiple `RENAME` commands:
- [source,esql]
- ----
- include::{esql-specs}/docs.csv-spec[tag=renameMultipleColumnsDifferentCommands]
- ----
|