0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PostgreSQLでハッシュパーティショニングの作成と、登録先確認

0
Last updated at Posted at 2024-08-08

いつも忘れるので、備忘録
後で説明も追加します

ハッシュパーティショニングの作成

salesテーブルに作成する場合
CREATE TABLE sales (
    id serial primary key,
    value int
) PARTITION BY HASH (id);

-- パーティションテーブルの作成
CREATE TABLE sales_p0 PARTITION OF sales FOR VALUES WITH (MODULUS 1000, REMAINDER 0);
CREATE TABLE sales_p1 PARTITION OF sales FOR VALUES WITH (MODULUS 1000, REMAINDER 1);
-- ...続けて999まで

登録先確認

-- 親テーブルからのデータを確認
SELECT tableoid::regclass AS partition, *
FROM テーブル名;

消したい時

-- 親テーブルを指定すれば、パーティションテーブルもまとめて削除できる
DROP TABLE IF EXISTS sales;

類似記事

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?