Skip to content

Instantly share code, notes, and snippets.

@muojp
Created August 15, 2012 08:44
Show Gist options
  • Save muojp/3357691 to your computer and use it in GitHub Desktop.
Save muojp/3357691 to your computer and use it in GitHub Desktop.
$ sqlite3 t.db
SQLite version 3.7.7.1 2011-06-28 17:39:05
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE t1(_id INTEGER, col1 VARCHAR(255));
sqlite> select * from t1;
sqlite> .schema t1
CREATE TABLE t1(_id INTEGER, col1 VARCHAR(255));
sqlite> CREATE TABLE t2(_id INTEGER, col1 VARCHAR(255), col2 INTEGER, PRIMARY KEY(_id, col2));
sqlite> .schema t2
CREATE TABLE t2(_id INTEGER, col1 VARCHAR(255), col2 INTEGER, PRIMARY KEY(_id, col2));
sqlite> INSERT INTO t2 (_id, col1, col2) VALUES(0, 'aa', 0);
sqlite> SELECT * FROM t2;
0|aa|0
sqlite> INSERT INTO t2 (_id, col1, col2) VALUES(0, 'bb', 1);
sqlite> INSERT INTO t2 (_id, col1, col2) VALUES(0, 'bb', 2);
sqlite> SELECT * FROM t2;
0|aa|0
0|bb|1
0|bb|2
sqlite> INSERT INTO t2 (_id, col1, col2) VALUES(0, 'bb', 2);
Error: columns _id, col2 are not unique
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment