title: "Column ’x’ does not exist" error for string literal ’x’ in PostgreSQL
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/13196572/column-mary-does-not-exist">Column ‘mary’ does not exist</a>  </p>
  </blockquote>
  
  
  
  <p>I need to check the values that can be accepted to a column through a check constraint. I need to use the check constraint, because this is for a college assignment.</p>
  
  <p>I use this code to create and add the constraint to the table.</p>
  
  <pre><code>CREATE TABLE Ereignis(
    E_Id Serial PRIMARY KEY,
    Typ varchar(15),
    Zeitpunkt timestamp,
    Ort varchar(32),
    Anzahl_Pers int
  );
  
  ALTER TABLE Ereignis ADD 
  CONSTRAINT typ_ch CHECK (Typ in (’Verkehrsunfall’, ’Hochwasser’, ’Sonstiges’));
  </code></pre>
  
  <p>Here is the error I get: </p>
  
  <pre><code> ERROR:  column "’verkehrsunfall’" does not exist
  </code></pre>
  
  <p>As I get from this error it tries to compare column typ with column verkehrsunfall, where as I try to check the values that column try can get is one of the (’Verkehrsunfall’, ’Hochwasser’, ’Sonstiges’) strings.</p>
  
  <p>This is exactly the same syntax what our lecturer showed us at the lecture. I am not sure if it is possible to compare varchars with check? Or what am I doing wrong?</p>
  
  <p>Here is the example from the lecture:</p>
  
  <pre><code>CREATE TABLE Professoren 
  (PersNr INTEGER PRIMARYKEY,
   Name VARCHAR( 3 0 ) NOT NULL ,
   Rang CHAR(2) CHECK (Rang in ('C2' ,'C3' ,'C4')) , 
   Raum INTEGER UNIQUE) ;
  </code></pre>