title: Partition existing tables using PostgreSQL 10
body: <p>I have gone through a bunch of documentation for PostgresSQL 10 partitioning but I am still not clear on whether existing tables can be partitioned. Most of the posts mention about partitioning existing tables using PostgreSQL 9.</p>
  
  <p>Also, in the official PostgresSQL website : <a href="https://www.postgresql.org/docs/current/static/ddl-partitioning.html" rel="nofollow noreferrer">https://www.postgresql.org/docs/current/static/ddl-partitioning.html</a>, it mentions 'It is not possible to turn a regular table into a partitioned table or vice versa'.</p>
  
  <p>So, my question is can existing tables be partitioned in PostgreSQL 10? 
  If the answer is YES, my plan is :</p>
  
  <ol>
  <li>Create a partitions</li>
  <li>Alter the existing table to include the range so new data goes into the new partition. Once that is done, write a script which loops over the master table and moves the data into the right partitions. </li>
  <li>Then, truncate the master table and enforce that nothing can be inserted into it. </li>
  </ol>
  
  <p>If the answer is NO, my plan is to make the existing table the first partition</p>
  
  <ol>
  <li>Create a new parent table and children(partitions). </li>
  <li>Perform light transaction which will rename the existing table to a partition table name and the new parent to the actual table name.</li>
  </ol>
  
  <p>Are there better ways to partition existing tables in PostgreSQL 10/9?</p>