Skip to content

Commit

Permalink
Merge 17afe7f into 99ceb56
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-bobkov authored Jan 9, 2025
2 parents 99ceb56 + 17afe7f commit 9a8a32c
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 8 deletions.
24 changes: 24 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,24 @@
## Database object naming rules {#object-naming-rules}

Every database object in {{ ydb-short-name }}, such as a table, view, topic, index or directory, has a name. In YQL statements, object 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).

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

- Object names can include the following characters:
- uppercase latin characters
- lowercase latin characters
- digits
- special characters: `.`, `-`, and `_`.
- Object name length must not exceed 255 characters.
- Objects cannot be created in folders, which names start with a dot, such as `.sys`, `.medatata`, `.sys_health`.

## 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 `_`.
- 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) %}

## 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 @@ -16,6 +16,8 @@ CREATE TOPIC topic_path (
All the parameters except the topic name are optional. By default, a topic is created without consumers. All
the omitted settings are also set by default (both for the topic and its consumers).

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

## Examples

Creating a topic without consumers with default settings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ AS <query>

* `security_invoker` (Bool) causes the underlying base relations to be checked against the privileges of the user of the view rather than the view owner. {#security_invoker}

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

## Notes {#notes}

The `security_invoker` option must always be set to true because the default behavior for views is to execute the query on behalf of the view's creator, which is not supported yet.
Expand Down Expand Up @@ -80,4 +82,4 @@ WHERE episodes.season_id = 1 AND episodes.episode_id = 1;
## See also

* [ALTER VIEW](alter-view.md)
* [DROP VIEW](drop-view.md)
* [DROP VIEW](drop-view.md)
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
25 changes: 25 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,25 @@
## Правила наименования объектов базы данных {#object-naming-rules}

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

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

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

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

Имена колонок в {{ 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 @@ -47,6 +47,8 @@ CREATE TOPIC topic_path (

{% endif %}

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

Следующая команда создаст топик без читателей с настройками по умолчанию:

```yql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ AS <запрос>

* `security_invoker` (Bool) - опция, при включении которой запрос, хранящийся в представлении, будет исполнен от имени пользователя, читающего из представления, а не от имени создателя представления. {#security_invoker}

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

## Замечания

`security_invoker` опция должна быть всегда выставлена в `TRUE`, потому что поведением по умолчанию для представления является исполнение сохранённого запроса от имени создателя представления, но эта возможность на данный момент не реализована в {{ ydb-short-name }}.
Expand Down Expand Up @@ -80,4 +82,4 @@ WHERE episodes.season_id = 1 AND episodes.episode_id = 1;
## См. также

* [ALTER VIEW](alter-view.md)
* [DROP VIEW](drop-view.md)
* [DROP VIEW](drop-view.md)
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

0 comments on commit 9a8a32c

Please sign in to comment.