New topic: Adding Columns...best practices
<http://forums.realsoftware.com/viewtopic.php?t=30449> Page 1 of 1 [ 4 posts ] Previous topic | Next topic Author Message jmorrison Post subject: Adding Columns...best practicesPosted: Mon Oct 12, 2009 8:19 pm Joined: Wed Oct 19, 2005 4:13 pm Posts: 198 Age old question, I'm sure... I create an awesome little app using REALbasic and sell it to a few customers. Later I find I want to add a few columns to the existing databases during my next software update. Obviously, I need a way to check to see if the table has a column, then add it if it's not there. Any suggestions on the best way to accomplish this? What is the SQLite syntax to check that a column exists? Do I just run a query on it and see if I get an error? Suggestions, please! Thanks! Jeff BTW...I'm still on RB2008r5...is the current release worth upgrading to? Top timhare Post subject: Re: Adding Columns...best practicesPosted: Mon Oct 12, 2009 10:00 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 6540 Location: Portland, OR USA You can run the FieldSchema method of the Database object to get a list of the columns. See the Database object in the Lang Ref for info. Tim Top jmorrison Post subject: Re: Adding Columns...best practicesPosted: Mon Oct 12, 2009 11:02 pm Joined: Wed Oct 19, 2005 4:13 pm Posts: 198 And once I have a list of columns, I can sort through and do append one when i don't find it in the list? Top timhare Post subject: Re: Adding Columns...best practicesPosted: Mon Oct 12, 2009 11:09 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 6540 Location: Portland, OR USA Yes. Use the "ALTER TABLE" sql command. I would just do them one at a time and not try to accumulate one big sql command. ALTER TABLE tablename ADD COLUMN columname columntype Tim Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 4 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
