title: How to convert a timestamp field to int8? Or just drop the column and make a new one?
body: <p>I have a PostgreSQL table with a column of type <code>timestamp</code>. I had included this column a while ago just in case I wanted to use it for something in the future. I am now looking to convert it into an <code>int8</code> and use it as an epoch time column. All rows of the table have this column set to <code>null</code> at the moment. When I try to alter the row using:</p>
  <pre><code>ALTER TABLE public.new_ambient_data
  ALTER COLUMN sensor_date TYPE int8 USING sensor_date::int8;
  </code></pre>
  <p>I get the error:</p>
  <blockquote>
  <pre><code>ERROR: cannot cast type timestamp without time zone to bigint
  </code></pre>
  </blockquote>
  <p>Is it better to just drop the column and make a new one of the data type that I want, or is here a better SQL script to convert the empty <code>timestamp</code> column to an <code>int8</code>.</p>
  <p>Note: The table in question has over a million rows in it.</p>