pg_pathman icon indicating copy to clipboard operation
pg_pathman copied to clipboard

Как задать партиционирование если таблица еще пустая?

Open Guzya opened this issue 8 months ago • 0 comments

Problem description

Имеются таблицы, еще пустые. На них надо задать партиционирование до заливки данных. Но не понятно как.

Воспользовался примером в одной из задач, но ни чего не вышло.

Environment

=# create table test_1(modification_time timestamp not null);
CREATE TABLE
=# SELECT create_range_partitions('test_1', 'modification_time', null::date, '1 day'::interval,0);
 create_range_partitions 
-------------------------
                       0
(1 row)

=# insert into test_1 values (now());
INSERT 0 1
=# insert into test_1 values (now()+'1 day'::interval);
INSERT 0 1

=# \d+ test_1
                                                  Table "public.test_1"
      Column       |            Type             | Collation | Nullable | Default | Storage | Stats target | Description 
-------------------+-----------------------------+-----------+----------+---------+---------+--------------+-------------
 modification_time | timestamp without time zone |           | not null |         | plain   |              | 

=# \d test_1
                              Table "public.test_1"
      Column       |            Type             | Collation | Nullable | Default 
-------------------+-----------------------------+-----------+----------+---------
 modification_time | timestamp without time zone |           | not null | 


=# drop table test_1 ;
ERROR:  cannot drop table test_1 because other objects depend on it
DETAIL:  sequence test_1_seq depends on table test_1
HINT:  Use DROP ... CASCADE to drop the dependent objects too.

Guzya avatar Jun 10 '24 13:06 Guzya