14 Aralık 2022 Çarşamba

CREATE TABLE

PARTITION BY X
5 çeşit partition yöntemi var. 

Eğer bölümleme yaptıktan sonra silmek istersek şöyle yaparız
ALTER TABLE customers REMOVE PARTITIONING;

1. RANGE partitioning
RANGE partitioning yazısına taşıdım. Sütün hangi aralığa girerse o bölümlemeye yazılır

2. LIST partitioning
LIST partitioning yazısına taşıdım. Sütün hangi listeye girerse o bölümlemeye yazılır

3. HASH partitioning
HASH partitioning  yazısına taşıdım. Sütun bir hash fonksiyonunda girdikten sonra dönen değer N kadar bölümlemeye ayrılır

4. KEY partitioning
Açıklaması şöyle
KEY partitioning is similar to partitioning by HASH, except that only one or more columns to be evaluated are supplied, and the SQL server provides its own hashing function. These columns can contain other than integer values, since the hashing function supplied by SQL guarantees an integer result regardless of the column data type. An extension to this type, LINEAR KEY, is also available.
Açıklaması şöyle
For this type of partitioning, the same as the LIST partitioning, the key has to be part of a primary/unique key be it single or compound.
ALTER TABLE
Örnek
Şöyle yaparız
CREATE TABLE sales ( saleDate date, … ) 
  PARTITION BY KEY(saleDate) PARTITIONS 16;

ALTER TABLE sales 
  ADD PARTITION (date = '2016-05-14');
Örnek
Şöyle yaparız
ALTER TABLE customers PARTITION BY KEY(registered_at) PARTITIONS 4;

5. COLUMN partitioning
Açıklaması şöyle
COLUMN partitioning is a variant of RANGE and LIST partitioning. COLUMNS partitioning enables the use of multiple columns in partitioning keys. All of these columns are taken into account both for the purpose of placing rows in partitions and for the determination of which partitions are to be checked for matching rows in partition pruning.
Örnek
Şöyle yaparız
CREATE TABLE rcx (
  a INT,
  b INT,
  c CHAR(3),
  d INT
)
PARTITION BY RANGE COLUMNS(a,d,c) (
  PARTITION p0 VALUES LESS THAN (5,10,'ggg'),
  PARTITION p1 VALUES LESS THAN (10,20,'mmm'),
  PARTITION p2 VALUES LESS THAN (15,30,'sss'),
  PARTITION p3 VALUES LESS THAN (MAXVALUE,MAXVALUE,MAXVALUE)
);


Hiç yorum yok:

Yorum Gönder

Soft Delete

Giriş Açıklaması  şöyle When using the soft delete mechanism on the database, you might run into a situation where a record with a unique co...