summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/storage_engine/index_primary.result
blob: 04b114f385e4ce5e2709ace9eb1d7ba789df8133 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a <INT_COLUMN> PRIMARY KEY,
b <CHAR_COLUMN>
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW KEYS IN t1;
Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment	Index_comment
t1	0	PRIMARY	1	a	#	#	NULL	NULL	#	#		
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
INSERT INTO t1 (a,b) VALUES (1,'c');
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). 
# If you got a difference in error message, just add it to rdiff file
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN> PRIMARY KEY,
b <CHAR_COLUMN> PRIMARY KEY
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
ERROR 42000: Multiple primary key defined
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN>,
PRIMARY KEY (a,b)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW INDEX IN t1;
Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment	Index_comment
t1	0	PRIMARY	1	a	#	#	NULL	NULL	#	#		
t1	0	PRIMARY	2	b	#	#	NULL	NULL	#	#		
INSERT INTO t1 (a,b) VALUES (1,'a'),(1,'b'),(2,'a'),(2,'b');
INSERT INTO t1 (a,b) VALUES (1,'b');
ERROR 23000: Duplicate entry '1-b' for key 'PRIMARY'
# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). 
# If you got a difference in error message, just add it to rdiff file
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN> KEY,
b <CHAR_COLUMN>,
<CUSTOM_INDEX> (b)
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW INDEX IN t1;
Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment	Index_comment
t1	0	PRIMARY	1	a	#	#	NULL	NULL	#	#		
t1	1	b	1	b	#	#	NULL	NULL	#	#		
DROP TABLE t1;
CREATE TABLE t1 (a <INT_COLUMN>,
b <CHAR_COLUMN> PRIMARY KEY
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW INDEX IN t1;
Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment	Index_comment
t1	0	PRIMARY	1	b	#	#	NULL	NULL	#	#		
ALTER TABLE t1 DROP INDEX `PRIMARY`;
ALTER TABLE t1 ADD CONSTRAINT PRIMARY KEY pk (a);
SHOW KEYS IN t1;
Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment	Index_comment
t1	0	PRIMARY	1	a	#	#	NULL	NULL	#	#		
ALTER TABLE t1 DROP PRIMARY KEY;
DROP TABLE t1;