Question

This is SQLite for Android...

I am inserting a new column using ALTER TABLE tablename ADD COLUMN.

I have 2 questions:

  1. Is there a way I can just copy values from existing columnA to this newly inserted/added columnB?

  2. I need to add another columnC, the value of which is MD5 hash output of columnA. Is there a way SQLite can add columnC and set its value to MD5 hash (either using an existing SQLite internal function or my custom function)

Was it helpful?

Solution

  1. UPDATE MyTable SET NewCol = columnA

  2. The Android DB API does not expose a mechanism for registering custom functions. You have to read all the columnA values, compute the hash in your code, and update the records one by one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top