mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> #MyISAM存储引擎其实更像一整堆表,所有的行数据都存放在MYD文件中,其B+树索引都是辅助索引,存放于MYI文件中,primary key索引和其他索引不同之处在于其必须是唯一的,并且不可为null值,其索引大小默认为1k,
mysql> show myisam_block_size;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'myisam_block_size' at line 1
mysql> show @@myisam_block_size;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@@myisam_block_size' at line 1
mysql> #innodb存储引擎不同的是,因为没有聚集索引,其索引叶子节点存放的不是主键值而是MYD文件中的物理位置
mysql>
mysql> #何时添加B+树索引 如果某个字段的取值范围很广,几乎没有重复,即是高选择性的 此时使用B+树
mysql>
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| MonthlyOrders |
| Nums |
| a |
| aa |
| animals |
| back |
| charTest |
| customers |
| dept_manager |
| emp |
| employees |
| g |
| mintable |
| new_emp |
| orders |
| point |
| pp |
| sales |
| sessions |
| t |
| test01 |
| timetest |
| tt |
| ttt |
| tttt |
| updatetime |
| x |
| xx |
| y |
| yeartest |
| yy |
| z |
+----------------+
32 rows in set (0.01 sec)
mysql> show indes from employees;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'indes from employees' at line 1
mysql> show index from employees;
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| employees | 0 | PRIMARY | 1 | id | A | 299685 | NULL | NULL | | BTREE | | |
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.07 sec)
mysql> show index from employees;
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| employees | 0 | PRIMARY | 1 | id | A | 300496 | NULL | NULL | | BTREE | | |
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.06 sec)
mysql> #随机取值 结果不一样
mysql> exit
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> #MyISAM存储引擎其实更像一整堆表,所有的行数据都存放在MYD文件中,其B+树索引都是辅助索引,存放于MYI文件中,primary key索引和其他索引不同之处在于其必须是唯一的,并且不可为null值,其索引大小默认为1k,
mysql> show myisam_block_size;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'myisam_block_size' at line 1
mysql> show @@myisam_block_size;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@@myisam_block_size' at line 1
mysql> #innodb存储引擎不同的是,因为没有聚集索引,其索引叶子节点存放的不是主键值而是MYD文件中的物理位置
mysql>
mysql> #何时添加B+树索引 如果某个字段的取值范围很广,几乎没有重复,即是高选择性的 此时使用B+树
mysql>
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| MonthlyOrders |
| Nums |
| a |
| aa |
| animals |
| back |
| charTest |
| customers |
| dept_manager |
| emp |
| employees |
| g |
| mintable |
| new_emp |
| orders |
| point |
| pp |
| sales |
| sessions |
| t |
| test01 |
| timetest |
| tt |
| ttt |
| tttt |
| updatetime |
| x |
| xx |
| y |
| yeartest |
| yy |
| z |
+----------------+
32 rows in set (0.01 sec)
mysql> show indes from employees;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'indes from employees' at line 1
mysql> show index from employees;
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| employees | 0 | PRIMARY | 1 | id | A | 299685 | NULL | NULL | | BTREE | | |
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.07 sec)
mysql> show index from employees;
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| employees | 0 | PRIMARY | 1 | id | A | 300496 | NULL | NULL | | BTREE | | |
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.06 sec)
mysql> #随机取值 结果不一样
mysql> exit