当前位置:网站首页>Mysql database index

Mysql database index

2022-06-25 22:54:00 Forestᝰ

Index Syntax
Look at the index showindexfrom Table name ; Index creation method 1 : Create index when creating table createtablecreate_index(idintprimarykey,namevarchar(10)unique,ageint,key(age)); Mode two : For existing tables , Add an index if the specified field is a string , You need to specify the length , It is recommended that the length be consistent with the length of the field when it is defined. If the field type is not a string , You can leave out the length section createindex The index name on Table name ( Field name ( length )) example :createindexage_indexoncreate_index(age);createindexname_indexoncreate_index(name(10)); Delete index :dropindex The index name on Table name ;3. The disadvantage of indexing is that although indexing greatly improves the query speed , At the same time, it will reduce the speed of updating the table , Such as on the table INSERT、UPDATE and DELETE, Because when updating tables ,MySQL Not only to save data , Also save the index file, but , In Internet applications , The query statement is much larger than the addition, deletion and modification statement , It can even occupy 80%~90%, So don't care too much , Only when importing big data , You can delete the index first , Then insert data in batch , Finally, add the index

原网站

版权声明
本文为[Forestᝰ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206251912256379.html

随机推荐