Skip to content

Instantly share code, notes, and snippets.

@mitchtabian
Last active May 4, 2022 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitchtabian/62464966b74d83c569075099aef6348e to your computer and use it in GitHub Desktop.
Save mitchtabian/62464966b74d83c569075099aef6348e to your computer and use it in GitHub Desktop.
/* Suppose I have the following table: */
CREATE TABLE {table} (
{id} STRING PRIMARY KEY,
{name} STRING NOT NULL COLLATE LOCALIZED,
{data} BLOB
)
/*
* Where {data} is is large object such as:
* class Data(
* val name: String, // <-- Same as {name} field in table
* // ... Whole bunch of other stuff
* )
*/
/*
* I want to:
* 1. Change STRING to TEXT type for {table}.{name} column
* 2. Populate updated {table}.{name} column with information from {table}.{data.name}
*/
/* What would the ALTER TABLE statement look like? Mostly unsure of how to select fields from a BLOB. I got this far: */
ALTER TABLE {table} DROP COLUMN {name};
ALTER TABLE {table} ADD COLUMN {name} TEXT NOT NULL COLLATE LOCALIZED;
UPDATE {table} SET {name} = ???
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment