Created
May 15, 2014 09:43
-
-
Save steelywing/47e3527a68a86195cd3e to your computer and use it in GitHub Desktop.
sqlite
This file contains 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
-- This will replace the other fields to default value | |
INSERT OR REPLACE INTO book(id, name) VALUES(1001, 'Programming'); | |
-- INSERT OR UPDATE (Method 1) | |
INSERT OR IGNORE INTO book(id) VALUES(1001); | |
UPDATE book SET name = 'Programming'; | |
-- INSERT OR UPDATE (Method 2) | |
INSERT OR REPLACE INTO book (id, name) | |
VALUES (1001, 'Programming', | |
(SELECT type FROM book WHERE id = 1001), | |
(SELECT price FROM book WHERE id = 1001), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment