title: Create Table Else Alter Table
body: <p>This seems to be a simple problem, but after a while of searching I can't figure out the answer.</p>
  
  <p>I currently have a MySQL table in my local database used by a webapp, and them same table on a database in a remote server. Right now, I'm using the <code>CREATE TABLE IF NOT EXISTS</code> command through PHP to create the table on the databases:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS users (  
    `id` int(10) NOT NULL AUTO_INCREMENT,  
    `username` varchar(18) NOT NULL,  
    PRIMARY KEY (`id`)  
  ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
  </code></pre>
  
  <p>However, let's say I make a modification to the local database, adding a collumn, for example. It would be really annoying to have to go and change the remote database every time I change the local one. Is there an easier way to run code to create a table if it doesn't exist, and if it does exist, make sure it's structure matches that of the create table structure?</p>
  
  <p>Here's an example, to make what I'm trying to convey a little clearer. Let's say on the local database I have a users table, and I decide that in my webapp I want to have another collumn, <code>password</code>. So I go to the local database and add a <code>password</code> collumn. Is there PHP/MySQL code I can run to check if the users table exists, and if it does, make sure it has a <code>password</code> collumn, and if not, add it?</p>