Skip to content

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

Description

@Guzya

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions