title: PostgreSQL10 - is it possible to do PARTITION BY LIST (col1, col2, .., colN)?
body: <p>I am looking at the PostgreSQL <a href="https://www.postgresql.org/docs/10/ddl-partitioning.html" rel="nofollow noreferrer">official documentation page on Table Partitioning</a> for my version of postgres.</p>
  <p>I would like to create table partitions over three columns, and I wish to use declarative partition with <code>BY LIST</code> method to do that.</p>
  <p>However, I cannot seem to find a good example on how to deal with more columns, and <code>BY LIST</code> specifically.</p>
  <p>In the aforementioned docs I only read:</p>
  <blockquote>
  <p>You may decide to use multiple columns in the partition key for range
  partitioning, if desired. (...) For example, consider a table range
  partitioned using columns lastname and firstname (in that order) as
  the partition key.</p>
  </blockquote>
  <p>It seems that declarative partition on multiple columns is only for <code>BY RANGE</code> or is that not right?</p>
  <p>However, if it is not, I found <a href="https://stackoverflow.com/a/63295849/1979665">an answer on SO</a> that tells me how to deal with <code>BY LIST</code> and one column. But in my case I have three columns.</p>
  <p>My idea would be to do something like the following (I am pretty sure it's wrong):</p>
  <pre><code>CREATE TABLE my_partitioned_table (
      col1 type CONSTRAINT col1_constraint CHECK (col1 = 1 or col1 = 0),
      col2 type CONSTRAINT col2_constraint CHECK (col2 = 'A' or col2 = 'B'),
      col3 type,
      col4 type) PARTITION BY LIST (col1, col2);
  
  CREATE TABLE part_1a PARTITION OF my_partitioned_table
      FOR VALUES IN (1, 'A');
  
  CREATE TABLE part_1b PARTITION OF my_partitioned_tabel
      FOR VALUES IN (1, 'B');
  
  ...
  </code></pre>
  <p>I would need a correct implemenation as the combination of possible partitions in my case is quite a lot.</p>