On Thu, 6 May 2004, Puneet Kishor wrote: > >Things that SQLite sucks at (if you pardon the expression) compared to >Access and FMPro -- ALTERing tables is a royal pain in the behind. I am >constantly in need of ALTERing the tables and queries (views) as I am >developing the application, and to do this is just... well, not nice.
I assume you have a copy of the source schema in a seperate file. All I do is: 1 Update source schema. 2 Compile schema into application. 3 Re-init the database using the new schema, having blown away the old database. If you have data you want to keep in step 3, write a migration tool to dump the data only to a text file of inserts (with named columns in the inserts) and import the data again after the schema is updated. You could update the SQLite shell to just output inserts in the correct format. All it would need is an update to the callback() function in shell.c, to output the column names in the insert. The following patch will do just that (not extensively tested! Aginst 2.8.13.) Apply in the sqlite directory with "patch -p1 < patch": --- sqlite.old/src/shell.c 2004-02-25 02:25:37.000000000 +0000 +++ sqlite/src/shell.c 2004-05-07 16:49:51.000000000 +0100 @@ -387,7 +387,12 @@ } case MODE_Insert: { if( azArg==0 ) break; - fprintf(p->out,"INSERT INTO %s VALUES(",p->zDestTable); + fprintf(p->out,"INSERT INTO %s(",p->zDestTable); + for(i=0; i<nArg; i++){ + char *zSep = i>0 ? ",": ""; + fprintf(p->out, "%s%s",zSep, azCol[i]); + } + fprintf(p->out,") VALUES(" ); for(i=0; i<nArg; i++){ char *zSep = i>0 ? ",": ""; if( azArg[i]==0 ){ Richard, is there a reason why column names earn't listed when outputting insert statements from the shell? If there is no reason, and noone finds problems with the above code, could this go into the next release? Or perhaps make it an option in the sqlite shell. Cheers, Christian -- /"\ \ / ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL X - AGAINST MS ATTACHMENTS / \ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]