-
Notifications
You must be signed in to change notification settings - Fork 9
YDB DDL Examples
Anton Kovalenko edited this page Apr 25, 2024
·
4 revisions
CREATE TABLE `my_column_table` (
Key Uint64 not null,
Value String,
PRIMARY KEY (Key)
)
PARTITION BY HASH(Key)
WITH (
STORE = COLUMN,
AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 10
);
ALTER TABLE `my_table` ADD INDEX `name_index` GLOBAL ON (`name`);
ALTER TABLE `my-table` ADD CHANGEFEED `my_cdc` WITH (
FORMAT = 'JSON',
MODE = 'UPDATES'
);
CREATE TABLE `table_with_config`
(
`id` Uint64,
`expire_at` Datetime,
`name` String,
PRIMARY KEY (`id`)
)
WITH (
AUTO_PARTITIONING_BY_SIZE = ENABLED,
AUTO_PARTITIONING_PARTITION_SIZE_MB = 512,
AUTO_PARTITIONING_BY_LOAD = ENABLED,
AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 2,
AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 8,
UNIFORM_PARTITIONS = 4,
READ_REPLICAS_SETTINGS = 'PER_AZ: 2',
TTL = Interval("PT1H") ON expire_at,
KEY_BLOOM_FILTER = ENABLED
)
CREATE EXTERNAL DATA SOURCE `my_external_data_source` WITH (
SOURCE_TYPE="ObjectStorage",
LOCATION="my_data_source_location",
AUTH_METHOD="NONE"
);
CREATE EXTERNAL TABLE my_external_table (
data json
) WITH (
DATA_SOURCE="my_external_data_source",
LOCATION="table_location",
FORMAT="json_as_string"
);