Last active
July 16, 2019 15:18
-
-
Save dinorahto/e2fda0c3342dd3e9396062ecc24b1326 to your computer and use it in GitHub Desktop.
Creating of a Table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val queryForDatabase = """ | |
| CREATE TABLE IF NOT EXISTS UpdatedTableProduct (idProduct TEXT PRIMARY KEY NOT NULL, name TEXT, nameClean TEXT, | |
| description TEXT, discount INT, skuId TEXT, hasAddedToCart INT, opened INT, notified INT""" | |
| database.execSQL(queryForDatabase) | |
| val queryCopyDataBase = """ | |
| INSERT OR REPLACE INTO UpdatedTableProduct (idProduct, name, nameClean, description, discount, | |
| skuId, hasAddedToCart, opened, notified) | |
| SELECT idProduct, name, nameClean, description, discount, | |
| skuId, hasAddedToCart, opened, notified FROM Product""" | |
| database.execSQL(queryCopyDataBase) | |
| database.execSQL("DROP TABLE Product") | |
| database.execSQL("ALTER TABLE UpdatedTableProduct RENAME TO Product") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment