Skip to content

Instantly share code, notes, and snippets.

@steelywing
Created May 15, 2014 09:43
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 steelywing/47e3527a68a86195cd3e to your computer and use it in GitHub Desktop.
Save steelywing/47e3527a68a86195cd3e to your computer and use it in GitHub Desktop.
sqlite
-- 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