1

I have dumped several .txt files to an SQLite database on my computer's hard disk using RSQLite package. Since the .txt files have no headers, I have to use the "header = FALSE" argument. Here is how my codes look:

for (i in (1:8)) {
dbWriteTable(conn = db, name = tbls[i], value = paths[i], 
             row.names = FALSE, header = FALSE, sep = "\t", 
             overwrite = TRUE)
}

Now I want to add column names to the tables in the SQLite database, how can I do that?

QY Luo
  • 331
  • 1
  • 4
  • 11
  • I'd suggest setting the column names before writing the table to SQLite, i.e. while the data is in the data.frame: `colnames(df) <- c('col1', 'col2')`. – Dmitry Grekov Mar 15 '16 at 05:32
  • 1
    Thanks. However the data I dumped to SQLite database is pretty big which is about 10g in size. I just don't think it is efficient to load the data in R first and create column names. Is there any way to directly edit tables in SQLite using RSQLite functions? – QY Luo Mar 15 '16 at 14:20
  • 2
    Ok, I see. Have a look at here then: http://stackoverflow.com/questions/805363/how-do-i-rename-a-column-in-a-sqlite-database-table – Dmitry Grekov Mar 16 '16 at 11:35

0 Answers0