title: Create a Partition Table in Postgresql
body: <p>I'm trying to find an example to create a partition table.
  I have some tables with many tuples and I can classify them according to a value of one column, but, I just find examples using range and date (my column is a varchar and, in other table, is a int/foreign key).
  I'm trying to speed my SELECT with this technique.</p>
  
  <p>Here one of my CREATE tables (column Source will be used to partition this table):</p>
  
  <pre><code>CREATE TABLE tb_hit_source (
  Hit_SourceId bigserial NOT NULL,
  Source varchar(50) NOT NULL,
  UniqueId varchar(50) NOT NULL,
  tb_hit_HitId int8 NOT NULL,
  CONSTRAINT tb_hit_source_ak_1 UNIQUE (Source, tb_hit_HitId, UniqueId) NOT DEFERRABLE INITIALLY IMMEDIATE,
  CONSTRAINT tb_hit_source_pk PRIMARY KEY (Hit_SourceId)
  );
  CREATE INDEX tb_hit_source_idx_1 on tb_hit_source (Source ASC);
  CREATE INDEX tb_hit_source_idx_2 on tb_hit_source (tb_hit_HitId ASC);
  ALTER TABLE tb_hit_source ALTER COLUMN Hit_SourceId SET DEFAULT nextval('"HitSourceId_seq_tb_hit_source"');;
  </code></pre>