On Sun, May 15, 2011 at 9:44 PM, romtek <rom...@gmail.com> wrote: > On Sun, May 15, 2011 at 5:10 PM, Mr. Puneet Kishor <punk.k...@gmail.com>wrote: >> > I want to rename date to dateAdded. >> >> sqlite doesn't support changing the name of a table column (and, neither >> you nor your user should be doing this -- there is something strange with >> your app requirements). > > I was describing what I have to do when I need to change a DB's schema. > Software isn't always perfect and sometimes needs to be changed.
Right, well, SQLite3 doesn't support renaming columns. Internally SQLite3 only stores the CREATE statements for all schema elements (plus actual b-trees for tables and indexes). Specifically SQLite3 does not store schema elements in any sort of parse and normalized form, which means that changing the names of schema elements that are embedded in others is quite difficult, as it would mean parsing the stored CREATE statements, editing them, then writing them back to the DB. This is why the pragma writable_schema approach works: you get to do what SQLite3 doesn't know how, but being human, you're likely to screw up, in which case you'd be left with an unusable DB (so be really, really careful if you use this approach). If you must use Jay's method at all, I recommend that you do something like what Jay described, but, first take some steps to make sure you get the edits right: create a new, dummy DB with the same schema as the original, load some dummy data as well (enough to be able to test all your views and triggers), record all the statements that you run, then test the heck out of your new DB, then think long and hard about this, and finally quiesce the real DB and apply the recorded transaction. > Thanks to you and everybody else who's provided a sample of code to do this, > but I want to be more productive in my software development. An analogy: if > I want to create a letter with pretty styles and maybe images, I will use MS > Word or, at least, Open Office. I will not write a program to do that :) > So, I want a web based tool I use to allow me to quickly and easily rename a > column. I don't see an analogy there. Here's one using Word and OpenOffice: if you want a feature that Word has but OpenOffice lacks but don't want or can use Word, and the only way to get what you want with OpenOffice is non-trivial, then what? You could... write the feature for OpenOffice, or you could find a way to switch to Word, or you could find a way to do without that feature, or you could follow those non-trivial steps. > Secondly, if I executed the above SQL code, what would happen to triggers, > etc. that are associated with the original table? You have to fix your triggers and views -- that's what SQLite3 doesn't have the code to do. It's missing. Nico -- _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users