Is it possible to add index to database table through R(RMySQL)
Question
I have created a table output and connected to database through RMySQL, and now I need to add index to the table, I searched around but didn't found what I need in R language, please help.
A small example of the table would look like this:
mth <- c(rep(1:2,5))
day <- c(rep(10,5),rep(11,5))
hr <- c(3,4,5,6,7,3,4,5,6,7)
v <- c(3,4,5,4,3,3,4,5,4,3)
A <- data.frame(cbind(mth,day,hr,v))
The index I need should include: "mth" + "day" + "hr". Thank you very much!
Solution
You can use dbSendQuery
to send SQL statements to the server. So you can create your table and/or add indices using SQL, and afterwards write your data using dbWriteTable
with append=TRUE
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow