通过简单的Sql语句创建表后,表是怎么存储的,以什么的方式进行存储的,占的磁盘空间是怎么算的?就是想通过深入学习,了解其内部构造结构。
MariaDB [db_test]> create table t8 (id int,sex char(1),username varchar(100),age tinyint,brithday date); Query OK, 0 rows affected (0.028 sec)
在磁盘中找到对应的数据表文件:
[root@172 /]# cd /var/lib/mysql/db_test [root@172 db_test]# ls db.opt t2.frm t2.ibd t3.frm t3.ibd t5.frm t5.ibd t6.frm t6.ibd t7.frm t7.ibd t8.frm t8.ibd
两份文件对应的大小分别是:t8.frm 633B,t8.ibd 96KB (98.304B)
[root@172 db_test]# hexdump -C t8.frm 00000000 fe 01 0a 0c 12 00 56 00 01 00 44 03 00 00 10 00 |......V...D.....| 00000010 3a 01 00 00 00 00 00 00 00 00 00 02 08 00 09 00 |:...............| 00000020 00 05 00 00 00 00 21 00 00 00 00 00 00 00 00 10 |......!.........| 00000030 00 00 00 3c 88 01 00 10 00 00 00 00 00 00 00 00 |...<............| 00000040 00 10 ad b8 52 30 3d b5 11 eb ac 4b 0c da 41 1d |....R0=....K..A.| 00000050 8a 5a b0 01 00 00 00 00 00 00 02 00 ff 00 00 00 |.Z..............| 00000060 00 00 00 00 00 00 ff 00 00 00 00 20 20 20 00 00 |........... ..| 00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 000001a0 00 00 06 00 49 6e 6e 6f 44 42 00 00 00 00 00 00 |....InnoDB......| // 表存储的存储引擎 000001b0 94 01 94 01 00 00 00 00 00 00 00 00 00 00 00 00 |................| 000001c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 000002b0 00 00 05 00 00 00 48 01 00 00 3a 01 1f 00 00 00 |......H...:.....| 000002c0 00 00 00 00 00 00 50 00 16 00 05 00 00 00 00 00 |......P.........| 000002d0 00 00 00 0b 00 02 00 00 1b 80 00 00 00 03 21 00 |..............!.| 000002e0 00 00 00 00 03 00 06 00 00 00 80 00 00 00 fe 21 |...............!| 000002f0 00 00 00 00 00 2c 01 09 00 00 00 80 00 00 00 0f |.....,..........| 00000300 21 00 00 00 00 00 04 00 37 01 00 0b 80 00 00 00 |!.......7.......| 00000310 01 21 00 00 00 00 00 0a 00 38 01 00 70 80 00 00 |.!.......8..p...| 00000320 00 0e 21 00 00 ff 69 64 ff 73 65 78 ff 75 73 65 |..!...id.sex.use| // 表的字段 00000330 72 6e 61 6d 65 ff 61 67 65 ff 62 72 69 74 68 64 |rname.age.brithd| 00000340 61 79 ff 00 |ay..| 00000344
竟然没有找到对应的字段属性及长度值,这块到底怎么看啊。。。看来还得有高人指点才行啊。