title: SQL : Insert and Update a new column from existing column
body: <p><a href="https://stackoverflow.com/questions/24215823/query-matching-string-tags">Query matching string tags</a></p>
  
  <p>SQL : Insert and Update a new column from existing column</p>
  
  <p>I want to insert a new column in my PostGRESQL data, parsing from an existing column.</p>
  
  <p>I have a string <code>http://google.com/sadfasdfsd&amp;AA=mytag&amp;SS=sdfsdf</code> that is being updated in the column <code>URL</code>. Then how could I insert a new column in this database with a name <code>AAtag</code>. I will be using Python to parse the string. Please help me to write the queries for the following tasks:</p>
  
  <hr>
  
  <p>Query 1. Insert a new column <code>AAtag</code> to this table.</p>
  
  <pre><code>ALTER TABLE table_name
  ADD AAtag varchar
  </code></pre>
  
  <p>Is it correct? <code>AAtag</code> needs to be quoted or not?</p>
  
  <hr>
  
  <p>Query 2. After I run the parsing script from the column <code>URL</code> (let's say I have the list of tags in Pyton list), I want to fill out the column <code>AAtag</code>.</p>
  
  <pre><code>UPDATE table_name
  SET AAtag='{0!f}'
  WHERE URL='{0!s}';
  </code></pre>
  
  <hr>