title: How to split name column into firstName and lastName columns in PostgreSQL?
body: <p>Assume this <code>User</code> table in PostgreSQL:</p>
  <pre><code>CREATE TABLE &quot;User&quot; (
      id SERIAL PRIMARY KEY,
      email text NOT NULL,
      name text,
  );
  
  </code></pre>
  <p>I want to split <code>name</code> into <code>firstName</code> and <code>lastName</code> and update the existing rows accordingly. I understand that I can use the following SQL to return the data as <code>firstName</code> and <code>lastName</code>:</p>
  <pre><code>SELECT 
    split_part(&quot;name&quot;, ' ', 1) AS &quot;firstName&quot;, 
    split_part(&quot;name&quot;, ' ', 2)  AS &quot;lastName&quot;
  FROM &quot;User&quot;;
  
  </code></pre>
  <p>I guess I now need to use <code>UPDATE</code> somehow in order to update the existing rows, but I'm not clear on the exact syntax.</p>