问题
I wrote a data.frame using
dbWriteTable(con, name='db_all', df, overwrite=T, row.names=F)
sucessfully to MySQL using RMySQL. Now I have a second data frame which has a similar structure and try to use
dbWriteTable(con,name='db_all',df1,append=T,row.names=F,overwrite=F)
which gives me
Error in .local(conn, statement, ...) : could not run statement: Unknown column 'zzz' in 'field list'>
In my SQL table I don't have that column name yet and would expect my append=T will add this column in my SQL table, which apparently it does not.
回答1:
The append will append data to the table, will not do an alter table adding columns.
You need to specify your columns if the name is not the same as in the dataframe using a named list e.g: field.types=list(dte="date", val="double(20,10)")
回答2:
What is the name of the unknown column? If it is "row_names" then you need to set the parameter row.names = FALSE
in dbWriteTable()
. Otherwise, it tries to include the row names in your data frame in the insert statement.
来源:https://stackoverflow.com/questions/37644420/unknown-column-in-field-list-error-rmysql