1. Insert multiple rows of data
INSERT INTO accounts VALUES (3, 8100.73), (4, 9400.10);
If the corresponding column has no value, replace it with NULL or use DEFAULT
INSERT INTO accounts (id, balance) VALUES (5); INSERT INTO accounts (id, balance) VALUES (6, DEFAULT); SELECT * FROM accounts WHERE id in (5, 6); +----+---------+ | id | balance | +----+---------+ | 5 | NULL | | 6 | NULL | +----+---------+ (2 rows)
2. Create an index
CREATE INDEX balance_idx ON accounts (balance DESC); or CREATE TABLE accounts ( id INT PRIMARY KEY, balance DECIMAL, INDEX balance_idx (balance) );
query index
SHOW INDEX FROM accounts; +----------+-------------+--------+-----+---------+-----------+---------+----------+ | Table | Name | Unique | Seq | Column | Direction | Storing | Implicit | +----------+-------------+--------+-----+---------+-----------+---------+----------+ | accounts | primary | true | 1 | id | ASC | false | false | | accounts | balance_idx | false | 1 | balance | DESC | false | false | | accounts | balance_idx | false | 2 | id | ASC | false | true | +----------+-------------+--------+-----+---------+-----------+---------+----------+