Home > database >  Why don't MySql compulsory primary key to take effect
Why don't MySql compulsory primary key to take effect

Time:09-22

Only from oracle to adopt to the mysql database, a lot of feelings do not understand, also can not find the information, consult BBS you great god help me ~ thank you


The following table statements,
 
The CREATE TABLE ` cyh_a ` (
` id ` int (5) NOT NULL,
` name ` varchar (20) COLLATE utf8_bin DEFAULT NULL,
` type ` int (11) the DEFAULT NULL,
The PRIMARY KEY (` id `)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin


ID field as the primary key

Use common query statements, and no index, if the list is more than millions of data, will be affect efficiency, but also not to let it go the index, and increase the false the where condition,
 the EXPLAIN the SELECT * FROM CYH_A; 


Search for information and then later found a function called compulsory primary key, but it still does not walk the primary key,,
 the EXPLAIN the SELECT * FROM CYH_A FORCE INDEX (PRI); 

Id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE CYH_A \ N \ N \ N \ N \ N ALL five 100.00 \ N


Excuse me this select a1, a2, a3, a4... From the table. When querying data, how to make it the default using the index,,

CodePudding user response:

ALL is not their clustering index, innodb is an index table
  • Related