<blockquote>
<p>ALTER TABLE buildings ADD PRIMARY KEY (osm_id);</p>
</blockquote>

<p>Don't do this. <code>osm_id</code> is not designed to be a primary key. You can use it like a primary key in many cases - any rows with the same osm_id will have the same tag columns, but it is not guaranteed to be unique. You can create a btree index on osm_id, just not unique.</p>

<p>If you require a primary key, add a serial column with postgres to make your own.</p>

<p>If you're designing something new, creating tables for specific features is what the <a href="https://github.com/openstreetmap/osm2pgsql/blob/master/docs/multi.md">multi backend</a> is designed for, and this is a better approach than a<code>CREATE TABLE ... AS ... approach</code></p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/osm2pgsql/issues/609#issuecomment-234189163">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AD2-7jc_VoHINf9Ekt27ASIUQHU0RZKTks5qXy0ygaJpZM4JOeb-">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AD2-7nOvmPB45FjxmByoTcPqzkzy3nygks5qXy0ygaJpZM4JOeb-.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/openstreetmap/osm2pgsql/issues/609#issuecomment-234189163"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>