title: Check If column already exist and if not Alter Table in sqlite
body: <p>I want to alter a table of sqlite in my app.</p>
  
  <p>now , i want to check that if that column already exists in my table or not ?</p>
  
  <p>hence if not exist i want to add that column with alter table syntex.</p>
  
  <p>currently i am using .</p>
  
  <pre><code>-(void) alterDB{
      sqlite3_stmt *statement; 
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory = [paths objectAtIndex:0];
      NSString *databasePath = [documentsDirectory stringByAppendingPathComponent:DATABASE_NAME];
  
      if(sqlite3_open([databasePath UTF8String], &amp;database) == SQLITE_OK)
      {
  
          NSString *updateSQL = [NSString stringWithFormat: @"ALTER TABLE diagramInfo ADD COLUMN testColumn VARCHAR"];
          const char *update_stmt = [updateSQL UTF8String];
          sqlite3_prepare_v2(database, update_stmt, -1, &amp;statement, NULL);
  
          if(sqlite3_step(statement)==SQLITE_DONE) 
          {
              UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"DB altered" message:@"Success" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];    
              [alert show];
              [alert release];
              alert=nil;
  
          }
          else 
          {
              UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"DB Updation" message:@"DB not Altered" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];   
              [alert show];
              [alert release];
              alert=nil;
          }   
          // Release the compiled statement from memory
          sqlite3_finalize(statement);    
          sqlite3_close(database);
      }
  }
  </code></pre>