Created
February 19, 2018 18:09
-
-
Save rohitpaulk/c773b771eb53f9356f8f9de708c29c70 to your computer and use it in GitHub Desktop.
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
use teamcom_shard_01; | |
DROP TABLE IF EXISTS contacts_test; | |
CREATE TABLE contacts_test ( | |
name VARCHAR(255), | |
email VARCHAR(255) NOT NULL, | |
public TINYINT(1), -- Values are either NULL, or True | |
workspace_id INT(11) unsigned NOT NULL, | |
creator INT(11) unsigned NOT NULL | |
, UNIQUE KEY `only_one_public` (workspace_id, public, email) | |
, UNIQUE KEY `creator_and_email` (workspace_id, creator, email) | |
); | |
EXPLAIN EXTENDED SELECT * | |
FROM contacts_test | |
WHERE workspace_id = 1234 | |
AND (creator = 1234 or public = 1) | |
\G; | |
show keys from contacts; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment