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)

有帮助吗?

解决方案

  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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top