16 Mart 2023 Perşembe

CREATE TABLE - RANGE partitioning

Giriş
Açıklaması şöyle
RANGE partitioning assigns rows to partitions based on column values falling within a given range.
CREATE TABLE veya ALTER TABLE ile kullanılabilir

CREATE TABLE
Örnek
Şöyle yaparız
CREATE TABLE Table (
  id INT NOT NULL,
  firstname VARCHAR(25) NOT NULL,
  joined DATE NOT NULL
)
PARTITION BY RANGE( id) (
  PARTITION p0 VALUES LESS THAN (100),
  PARTITION p1 VALUES LESS THAN (200),
  PARTITION p2 VALUES LESS THAN (300)
);
ALTER TABLE
Örnek
Şöyle yaparız
ALTER TABLE customers
PARTITION BY RANGE (id)
(
   PARTITION p0 VALUES LESS THAN (5000000),
   PARTITION p1 VALUES LESS THAN (10000000),
   PARTITION p2 VALUES LESS THAN (15000000),
   PARTITION pmax VALUES LESS THAN MAXVALUE
);
# query a single partition
SELECT COUNT(id) FROM customers PARTITION (pmax) 
WHERE registered_at > "2023-01-13 00:00:00";

Hiç yorum yok:

Yorum Gönder

CREATE EVENT - Scheduled Task İçindir

Örnek Şöyle yaparız CREATE EVENT myevent     ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR     DO       UPDATE myschema.mytable SET myc...