问题
I can use sqlSave to create a new table and to append data to that table, but I want the tablet to have some additional columns (for instance, an "ID" autoincrementing column - I am manually adding these columns after creating the table and testing that I can save to it and append to it). As soon as I try to use sqlSave after adding those columns I get an error when trying to use sqlSave to append more data
Error in odbcUpdate... missing columns in 'data'
So I added an ID column to my data frame (so its columns would match my database table) and tried setting it to "NULL", NULL, and "". I keep getting the same error.
Any ideas?
Thanks, Aerik
P.S. I'm using RODBC with MySQL OOBC driver version 5.1
回答1:
Ah, I got it. The sqlSave function seems to lowercase everything. I'm not sure what checks it's doing behind the scenes, but if I make an "id" column it works, but an "ID" column does not.
回答2:
Try the case="nochange" argument in odbcConnect. I'm using RODBC (1.3-10) with MySQL ODBC driver version 5.2 and it works for me.
来源:https://stackoverflow.com/questions/14882754/how-to-use-sqlsave-function-with-existing-table-in-r