14.9. The CSV Storage Engine

MySQL 5.0

14.9. The CSV Storage Engine

The storage engine stores data in text files using comma-separated values format.

To enable this storage engine, use the option to configure when you build MySQL.

The storage engine is included in MySQL-Max binary distributions. To enable this storage engine if you build MySQL from source, invoke configure with the option.

To examine the source for the engine, look in the directory of a MySQL source distribution.

When you create a table, the server creates a table format file in the database directory. The file begins with the table name and has an extension. The storage engine also creates a data file. Its name begins with the table name and has a extension. The data file is a plain text file. When you store data into the table, the storage engine saves it into the data file in comma-separated values format.

mysql> 
Query OK, 0 rows affected (0.12 sec)

mysql> 
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> 
+------+------------+
| i    | c          |
+------+------------+
|    1 | record one |
|    2 | record two |
+------+------------+
2 rows in set (0.00 sec)

If you examine the file in the database directory created by executing the preceding statements, its contents should look like this:

"1","record one"
"2","record two"

This format can be read, and even written, by spreadsheet applications such as Microsoft Excel or StarOffice Calc.

The storage engine does not support indexing.