How many columns does a MySQL index have? Real test example _ MySQL

Source: Internet
Author: User
Tags mysql index
How many columns does a MySQL index have? A real test example of bitsCN.com can contain a maximum of 16 columns.

Create table test (
F1 int,
F2 int,
F3 int,
F4 int,
F5 int,
F6 int,
F7 int,
F8 int,
F9 int,
F10 int,
F11 int,
F12 int,
F13 int,
F14 int,
F15 int,
F16 int,
F17 int
);

Create index idx_test_16 on test (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16 );
Create index idx_test_17 on test (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17 );

The running result is as follows:


Mysql> create table test (
-> F1 int,
-> F2 int,
-> F3 int,
-> F4 int,
-> F5 int,
-> F6 int,
-> F7 int,
-> F8 int,
-> F9 int,
-> F10 int,
-> F11 int,
-> F12 int,
-> F13 int,
-> F14 int,
-> F15 int,
-> F16 int,
-> F17 int
-> );
Query OK, 0 rows affected (0.06 sec)

Mysql>
Mysql> create index idx_test_16 on test (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16 );
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0

Mysql> create index idx_test_17 on test (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17 );
ERROR 1070 (42000): Too primary key parts specified; max 16 parts allowed
Mysql>
BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.