Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs on ALTER TABLE ALTER INDEX #1

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ ALTER TABLE episodes DROP column is_deleted;

{% if feature_secondary_index %}

## Adding or removing a secondary index {#secondary-index}
## Secondary indexes {#secondary-index}

### Adding an index {#add-index}

```ADD INDEX```: Adds an index with the specified name and type for a given set of columns. The code below adds a global index named ```title_index``` for the ```title``` column.

Expand All @@ -36,17 +38,49 @@ ALTER TABLE `series` ADD INDEX `title_index` GLOBAL ON (`title`);

You can specify any index parameters from the [`CREATE TABLE`](../create_table#secondary_index) command.

Deleting an index:
You can also add a secondary index using the {{ ydb-short-name }} CLI [table index](https://ydb.tech/en/docs/reference/ydb-cli/commands/secondary_index#add) command.

### Altering an index {#alter-index}

Indexes have type-specific parameters that can be tuned. Global indexes, whether [synchronous](../../../../concepts/secondary_indexes#sync) or [asynchronous](../../../../concepts/secondary_indexes#async), are implemented as hidden tables, and their automatic partitioning settings can be adjusted just like [those of regular tables](#additional-alter).

```sql
ALTER TABLE table_name ALTER INDEX index_name SET partitioning_setting_name value;
ALTER TABLE table_name ALTER INDEX index_name SET (partitioning_setting_name_1 = value_1, ...);
```

`table_name`: The name of the table whose index is to be altered.

`index_name`: The name of the index to be altered.

`partitioning_setting_name`: The name of the setting to be altered, which should be one of the following:
- [AUTO_PARTITIONING_BY_SIZE]({{ concept_table }}#auto_partitioning_by_size)
- [AUTO_PARTITIONING_BY_LOAD]({{ concept_table }}#auto_partitioning_by_load)
- [AUTO_PARTITIONING_PARTITION_SIZE_MB]({{ concept_table }}#auto_partitioning_by_size_mb)
- [AUTO_PARTITIONING_MIN_PARTITIONS_COUNT]({{ concept_table }}#auto_partitioning_min_partitions_count)
- [AUTO_PARTITIONING_MAX_PARTITIONS_COUNT]({{ concept_table }}#auto_partitioning_max_parririons_count)

{% note info %}

These settings cannot be [reset](#additional-reset).

{% endnote %}

`value`: The new value for the setting. Possible values include:
- `ENABLED` or `DISABLED` for `AUTO_PARTITIONING_BY_SIZE` and `AUTO_PARTITIONING_BY_LOAD`
- integer of `Uint64` type for the other settings

### Deleting an index {#drop-index}

```DROP INDEX```: Deletes the index with the specified name. The code below deletes the index named ```title_index```.

```sql
ALTER TABLE `series` DROP INDEX `title_index`;
```

You can also add or remove a secondary index using the {{ ydb-short-name }} CLI [table index](https://ydb.tech/en/docs/reference/ydb-cli/commands/secondary_index) command.
You can also remove a secondary index using the {{ ydb-short-name }} CLI [table index](https://ydb.tech/en/docs/reference/ydb-cli/commands/secondary_index#drop) command.

## Renaming a secondary index {#rename-secondary-index}
### Renaming a index {#rename-index}

`RENAME INDEX`: Renames the index with the specified name.

Expand Down
Loading