title: How to use same db path to create multiple tables using SQLite in iOS?
body: <p>I am developing an iOS application in objective-c using sqllite3 as local DB to store some data. I am trying to use multiple tables with the same db path, but it does not allow me to do so. </p>
  
  <p>For instance, If I try to create multiple tables in same DB {db path as DB1} then the second table is not created.</p>
  
  <p>But if I try to create different tables in different db paths, then it functions normally. ex : db path as DB1 for table T1 , DB2 for table T2 and so on.</p>
  
  <p>Here is my code:</p>
  
  <p>Statement to create table :</p>
  
  <pre><code>  -(int) createTable
  {
  
      sqlite3* db = NULL;
              int rc=0;
  
              rc = sqlite3_open_v2([[self getDbFilePath] cStringUsingEncoding:NSUTF8StringEncoding], &amp;db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
              if (SQLITE_OK != rc)
              {
                  sqlite3_close(db);
                  NSLog(@"Failed to open db connection");
              }
              else
              {
  
              char * query ="CREATE TABLE IF NOT EXISTS userinfo (id INTEGER PRIMARY KEY AUTOINCREMENT, selfuser  TEXT, pic TEXT, name TEXT, gender TEXT, link TEXT )";
                  char * errMsg;
                  rc = sqlite3_exec(db, query,NULL,NULL,&amp;errMsg);
  
                  if(SQLITE_OK != rc)
                  {
                      NSLog(@"Failed to create table rc:%d, msg=%s",rc,errMsg);
                  }
  
                  sqlite3_close(db);
  
              query = "CREATE TABLE IF NOT EXISTS EVENTS (id INTEGER PRIMARY KEY AUTOINCREMENT, id  TEXT, info TEXT, date TEXT, no TEXT, name TEXT, time TEXT,userid TEXT, aName TEXT, day TEXT, FirstName TEXT, Pic TEXT,Accepted TEXT,rank TEXT );";
  
          rc = sqlite3_exec(db, query,NULL,NULL,&amp;errMsg);
                  if(SQLITE_OK != rc)
                  {
                      NSLog(@"Failed to create table rc:%d, msg=%s",rc,errMsg);
                  }
          sqlite3_close(db);
          }
                  return rc;
      } 
  </code></pre>
  
  <p>Help is much appreciated, thanks in advance! </p>