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

Added info on table naming rules #11319

Merged
merged 11 commits into from
Feb 10, 2025
26 changes: 26 additions & 0 deletions ydb/docs/en/core/concepts/datamodel/_includes/table-name-rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Table naming rules

Every table in {{ ydb-short-name }} has a name. In YQL statements, table names are specified by identifiers that can be enclosed in backticks or not. For more information on identifiers, refer to [{#T}](../../../yql/reference/syntax/lexer.md#keywords-and-ids).
anton-bobkov marked this conversation as resolved.
Show resolved Hide resolved

Table names in {{ ydb-short-name }} must meet the following requirements:

- Table names can include the following characters:
anton-bobkov marked this conversation as resolved.
Show resolved Hide resolved
- uppercase latin characters
- lowercase latin characters
- digits
- special characters: `!`, `"`, `#`, `$`, `%`, `&`, `'`, `(`, `)`, `*`, `+`, `,`, `-`, `.`, `:`, `;`, `<`, `=`, `>`, `?`, `@`, `[`, `\`, `]`, `^`, `_`, `` ` ``, `{`, `|`, `}`, `~`.
anton-bobkov marked this conversation as resolved.
Show resolved Hide resolved
- Table name length must not exceed 255 characters.
- Table names must not contain dots only.
- Tables cannot be created in the system folder (`.sys`).
anton-bobkov marked this conversation as resolved.
Show resolved Hide resolved

## Column naming rules

Column names in {{ ydb-short-name }} must meet the following requirements:

- Column names can include the following characters:
- uppercase latin characters
- lowercase latin characters
- digits
- special characters: `-` and `_`.
anton-bobkov marked this conversation as resolved.
Show resolved Hide resolved
- Column names must not start with the system prefix `__ydb_`.

4 changes: 3 additions & 1 deletion ydb/docs/en/core/concepts/datamodel/_includes/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Please note that currently, the `NOT NULL` constraint can only be applied to col

{{ ydb-short-name }} supports the creation of both row-oriented and column-oriented tables. The primary difference between them lies in their use-cases and how data is stored on the disk drive. In row-oriented tables, data is stored sequentially in the form of rows, while in column-oriented tables, data is stored in the form of columns. Each table type has its own specific purpose.

{% include [#{T}](./table-name-rules.md) %}
anton-bobkov marked this conversation as resolved.
Show resolved Hide resolved

## Row-oriented tables {#row-oriented-tables}

Row-oriented tables are well-suited for transactional queries generated by Online Transaction Processing (OLTP) systems, such as weather service backends or online stores. Row-oriented tables offer efficient access to a large number of columns simultaneously. Lookups in row-oriented tables are optimized due to the utilization of indexes.
Expand Down Expand Up @@ -210,7 +212,7 @@ At the moment, not all functionality of column-oriented tables is implemented. T
* Adding data to column-oriented tables using the SQL INSERT statement.
* Deleting data from column-oriented tables using the SQL DELETE statement. In fact, deletion is only possible after the TTL data retention time has expired.

## Partitioning of a column-oriented table {#olap-tables-partitioning}
### Partitioning column-oriented tables {#olap-tables-partitioning}

Unlike row-oriented {{ ydb-short-name }} tables, you cannot partition column-oriented tables by primary keys but only by specially designated partitioning keys. Partitioning keys constitute a subset of the table's primary keys.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
ALTER TABLE old_table_name RENAME TO new_table_name;
```

{% if oss == true and backend_name == "YDB" %}

{% cut "See table and column naming rules" %}

{% include [table naming rules](../../../../concepts/datamodel/_includes/table-name-rules.md) %}

{% endcut %}

{% endif %}

If a table with the new name already exists, an error will be returned. The ability to transactionally replace a table under load is supported by specialized methods in CLI and SDK.

{% note warning %}
Expand All @@ -22,4 +32,4 @@ Renaming can be used to move a table from one directory within the database to a

``` yql
ALTER TABLE `table1` RENAME TO `/backup/table1`;
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ The invocation of `CREATE TABLE` creates {% if concept_table %}a [table]({{ conc

{% if oss == true and backend_name == "YDB" %}

{% cut "See table and column naming rules" %}

{% include [table naming rules](../../../../concepts/datamodel/_includes/table-name-rules.md) %}

{% endcut %}

{% if feature_olap_tables %}

{{ ydb-short-name }} supports two types of tables:
Expand Down
27 changes: 27 additions & 0 deletions ydb/docs/ru/core/concepts/datamodel/_includes/table-name-rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Правила наименования таблиц

У каждой таблицы в {{ ydb-short-name }} есть имя. В YQL-выражениях имена таблиц указываются с помощью идентификаторов, заключённых в обратные кавычки (`` ` ``) или без этих символов. Для более подробной информации об идентификаторах, см. [{#T}](../../../yql/reference/syntax/lexer.md#keywords-and-ids).

Имена таблиц в {{ ydb-short-name }} должны соответствовать следующим требованиям:

- Имя таблицы может состоять из следующих символов:
- прописные (заглавные) латинские буквы;
- строчные латинские буквы;
- цифры;
- специальные символы: `!`, `"`, `#`, `$`, `%`, `&`, `'`, `(`, `)`, `*`, `+`, `,`, `-`, `.`, `:`, `;`, `<`, `=`, `>`, `?`, `@`, `[`, `\`, `]`, `^`, `_`, `` ` ``, `{`, `|`, `}`, `~`.
- Длина имени таблицы не должна превышать 255 символов.
- Имя таблицы не должно состоять только из точек.
- Таблицы не должны создаваться в системной папке (`.sys`).

## Правила наименования колонок

Имена колонок в {{ ydb-short-name }} должны соответствовать следующим требованиям:

- Имя колонки может состоять из следующих символов:
- прописные латинские буквы;
- строчные латинские буквы;
- цифры;
- специальные символы: `-` и `_`.
- Длина имени колонки не должна превышать 255 символов.
- Имя колонки не должно начинаться с системного префикса `__ydb_`.

2 changes: 2 additions & 0 deletions ydb/docs/ru/core/concepts/datamodel/_includes/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ CREATE TABLE article (

{{ ydb-short-name }} поддерживает создание строковых и колоночных таблиц. Основное их отличие — в области применения и формате хранения данных на жестком диске. Для строковых таблиц данные хранятся последовательно в виде строк, а для колоночных — в виде столбцов. У каждого типа таблиц свое предназначение.

{% include [table naming rules](./table-name-rules.md) %}

## Строковые таблицы {#row-oriented-tables}

Строковые таблицы хорошо подходят для транзакционных запросов, которые генерируют Online Transaction Processing (OLTP) системы, например, бекэнды сервисов погоды или интернет-магазинов. Строковые таблицы предоставляют эффективный доступ к большому количеству столбцов одновременно. Поиск по строковым таблицам работает очень быстро, за счет использования индексов.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
ALTER TABLE old_table_name RENAME TO new_table_name;
```

{% if oss == true and backend_name == "YDB" %}

{% cut "См. правила наименования таблиц и колонок" %}

{% include [table naming rules](../../../../concepts/datamodel/_includes/table-name-rules.md) %}

{% endcut %}

{% endif %}

Если таблица с новым именем существует, будет возвращена ошибка. Возможность транзакционной подмены таблицы под нагрузкой поддерживается специализированными методами в CLI и SDK.

{% note warning %}
Expand All @@ -22,4 +32,4 @@ ALTER TABLE old_table_name RENAME TO new_table_name;

```yql
ALTER TABLE `table1` RENAME TO `/backup/table1`;
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@

{% if oss == true and backend_name == "YDB" %}

{% cut "См. правила наименования таблиц и колонок" %}

{% include [table naming rules](../../../../concepts/datamodel/_includes/table-name-rules.md) %}

{% endcut %}

{% if feature_olap_tables %}

{{ ydb-short-name }} поддерживает два типа таблиц:
Expand Down Expand Up @@ -95,15 +101,15 @@ WITH (
{% if feature_column_container_type == true %}

Для неключевых колонок допускаются любые типы данных{% if feature_serial %} , кроме [серийных](../../types/serial.md) {% endif %}, для ключевых - только [примитивные](../../types/primitive.md){% if feature_serial %} и [серийные](../../types/serial.md){% endif %}. При указании сложных типов (например, `List<String>`) тип заключается в двойные кавычки.

{% else %}

{% if feature_serial %}

Для ключевых колонок допускаются только [примитивные](../../types/primitive.md) и [серийные](../../types/serial.md) типы данных, для неключевых колонок допускаются только [примитивные](../../types/primitive.md).

{% else %}

Для ключевых и неключевых колонок допускаются только [примитивные](../../types/primitive.md) типы данных.

{% endif %}
Expand Down Expand Up @@ -183,7 +189,7 @@ WITH (
AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 10
);
```

Такой код создаст колоночную таблицу с 10-ю партициями. С полным списком опций партиционирования колоночных таблиц можно ознакомиться в разделе [{#T}](../../../../concepts/datamodel/table.md#olap-tables-partitioning) статьи [{#T}](../../../../concepts/datamodel/table.md).


Expand Down
Loading