Regardless of the storage engine you choose, every MySQL table you create is represented, on disk, by a .frm file, which describes the table's format (i.e. the table definition). The file bears the same name as the table, with a .frm extension. The .frm format is the same on all platforms but in the description of the .frm format that follows, the examples come from tables created under the Linux operating system. First, let's create an example table, using the mysql client: mysql> CREATE TABLE table1 (column1 CHAR(5)) ENGINE=MYISAM COMMENT '*'; Query OK, 0 rows affected (0.00 sec) The .frm file associated with table1 can be located in the directory that represents the database (orschema) to which the table belongs. The datadir variable contains the name of this directory:
The DATABASE() function contains the name of the relevant database:
Since MySQL stores .frm files in datadir/database_name, it's a simple matter to locate the corresponding
.frm file for table1. For example, within a Linux shell:
You'll see a response like the following:
The .MYD and .MYI files are not our concern here; they are described elsewhere in this MySQL internals
manual. To understand the .frm format, let's look at table1.frm using a hexadecimal-dump utility;
the contents are show below.
The details shown above might change, especially since there is a transition underway from an old("binary") format to a new ("text based") .frm format. You can confirm that the details are correct by comparing this description with the statements in sql/table.cc, create_frm(). The table below explains the meaning of each byte in the hexadecimal dump shown in the above example. The Offset column shows the byte position in the file; Length is the number of bytes; Value is what's in that byte position for that length (remember that storage is "low byte first" so 0010 means 1000!); and Explanation provides a brief explanation of the contents.
The .frm file for a partitioned table contains partition information, in clear text, in addition to the usual table definition details. Let's create a partitioned table and do a hexadecimal dump of its .frm.
The hexadecimal dump from table2 is shown below:
In the example output, notice that position 00001010 and following contains the clear text of the CREATE TABLE ... PARTITION clause and not just the MYISAM engine information, as in table1, which shows the .frm of a non-partitioned table.
Finally, CREATE VIEW also causes creation of a .frm file, but a view .frm bears no resemblance to a base table .frm; it's purely textual. Here's an example of a .frm for a view made with:
Just looking at the text will tell you what it's about. For example let's do another hexadecimal dump; the contents are shown below.
MySQL Related Interview Questions
|PHP Interview Questions||MySQL Interview Questions|
|PHP+MySQL Interview Questions||Drupal Interview Questions|
|MYSQL DBA Interview Questions||PHP5 Interview Questions|
|WordPress Interview Questions||Joomla Interview Questions|
|CakePHP Interview Questions||CodeIgniter Interview Questions|
|PHP7 Interview Questions|
A Guided Tour Of The Mysql Source Code
Important Algorithms And Structures
How Mysql Performs Different Selects
How Mysql Transforms Subqueries
Mysql Client/server Protocol
Prepared Statements And Stored Routines
Myisam Storage Engine
Innodb Storage Engine
Writing A Custom Storage Engine
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.