---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://ydb.tech/docs/en/yql/reference/syntax/alter_table/family.md?version=v25.3
  - https://ydb.tech/docs/ru/yql/reference/syntax/alter_table/family.md?version=v25.3
  - href: en/yql/reference/syntax/alter_table/family.md
    type: text/markdown
    title: Markdown version
  - href: ../../../../llms.txt
    type: text/markdown
    title: llms.txt
sourcePath: en/core/yql/reference/syntax/alter_table/family.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ydb.tech/docs/en/llms.txt

# Changing column groups

The mechanism of [column groups](https://ydb.tech/docs/en/concepts/datamodel/table.md?version=v25.3#column-groups) allows for improved performance of partial row read operations by dividing the storage of table columns into several groups. The most commonly used scenario is to organize the storage of infrequently used attributes into a separate column group.

## Creating column groups {#creating-column-groups}

`ADD FAMILY`: Creates a new group of columns in the table. The code below creates the `family_small` column group in the `series_with_families` table.

```yql
ALTER TABLE series_with_families ADD FAMILY family_small (
    DATA = "ssd",
    COMPRESSION = "off"
);
```

## Modifying column groups {#mod-column-groups}

Using the `ALTER COLUMN` command, you can change a column group for the specified column. The code below for the `release_date` column in the `series_with_families` table changes the column group to `family_small`.

```sql
ALTER TABLE series_with_families ALTER COLUMN release_date SET FAMILY family_small;
```

The two previous commands from listings 8 and 9 can be combined into one `ALTER TABLE` call. The code below creates the `family_small` column group and sets it for the `release_date` column in the `series_with_families` table.

```yql
ALTER TABLE series_with_families
    ADD FAMILY family_small (
        DATA = "ssd",
        COMPRESSION = "off"
    ),
    ALTER COLUMN release_date SET FAMILY family_small;
```

Using the `ALTER FAMILY` command, you can change the parameters of the column group.


### Changing storage type


<!-- source: en/_includes/only_allow_for_oltp_note.md -->
{% note warning %}

<!-- source: en/_includes/only_allow_for_oltp_text.md -->
Supported only for [row-oriented](https://ydb.tech/docs/en/concepts/datamodel/table.md?version=v25.3#row-oriented-tables) tables.
<!-- endsource: en/_includes/only_allow_for_oltp_text.md -->

{% endnote %}
<!-- endsource: en/_includes/only_allow_for_oltp_note.md -->


The code below changes the storage type to `rot` for the `default` column group in the `series_with_families` table:

```yql
ALTER TABLE series_with_families ALTER FAMILY default SET DATA "rot";
```

{% note info %}

Available types of storage devices depend on the YDB cluster configuration.

{% endnote %}

### Changing compression codec

The code below changes the compression codec to `lz4` for the `default` column group in the `series_with_families` table:

```yql
ALTER TABLE series_with_families ALTER FAMILY default SET COMPRESSION "lz4";
```

### Changing compression level of codec


<!-- source: en/_includes/only_allow_for_olap_note.md -->
{% note warning %}

<!-- source: en/_includes/only_allow_for_olap_text.md -->
Supported only for [column-oriented](https://ydb.tech/docs/en/concepts/datamodel/table.md?version=v25.3#column-oriented-tables) tables.
<!-- endsource: en/_includes/only_allow_for_olap_text.md -->

{% endnote %}
<!-- endsource: en/_includes/only_allow_for_olap_note.md -->


The code below changes the compression level of codec if it supports different compression levels for the `default` column group in the `series_with_families` table:

```yql
ALTER TABLE series_with_families ALTER FAMILY default SET COMPRESSION_LEVEL 5;
```

You can specify any parameters of a group of columns from the [`CREATE TABLE`](https://ydb.tech/docs/en/yql/reference/syntax/create_table/index.md?version=v25.3) command.
