InnoDB :
It is a transactional storage engine with a capacity to commit, rollback and crash recovery. It is optimized for concurrent use of data among many users and for very high performance even with large amounts of data. It also supports the foreign key. If you do not use InnoDB tables, you can start the server with the - skip-innodb. But if you use them, you should give the server the information on file to use for the data. Here is an example of configuration options related to the InnoDB option file:
Code:
innodb_data_home_dir = / ibdata
innodb_data_file_path = ibdata1: 50M; ibdata2: 50M: autoextend: max: 500M
innodb_buffer_pool_size = 90M
innodb_additional_mem_pool_size = 10M
innodb_log_group_home_dir = / iblogs
innodb_log_files_in_group = 2
innodb_log_file_size = 20M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 75
skip-external-locking
max_connections = 100
read_buffer_size = 1M
sort_buffer_size = 1M
innodb_data_home_dir indicates the directory for data files. If not specified, InnoDB uses the MySQL data directory. If the set is empty, you must specify the full path to innodb_data_file_path, indicating the names of files that will be used as a tablespace. You can specify one or more: the example we have a file ibdata1 of 50 megabytes and 50 megabytes of a file ibdata2 which may extend up to 500. Autoextend option may be given only on the last file. Please note the maximum size of the files on your system to indicate the max parameter. The specified directory must exist, because the server can not create them. innodb_buffer_pool_size should be about half the memory of your computer.
innodb_log_file_size should be about 25% of the size of the buffer pool. The other settings should be fine as is. If you do not set the configuration settings, InnoDB will create a data file of 10MB and two 5MB log files from each directory in the MySQL database. We said that InnoDB supports the use of transactions. Each connection to the MySQL server will start in autocommit mode, which means that all the update statements are made effective immediately. If you turn off the autocommit with SET AUTOCOMMIT = 0, the amendments will become operative only when you execute the COMMIT statement. If instead performed ROLLBACK will undo all changes to the previous COMMIT. You can use transactions without disabling the autocommit, beginning with START TRANSACTION or BEGIN and ending with COMMIT or ROLLBACK. Manages the InnoDB AUTO_INCREMENT value for a table in a special way: this is in fact calculated the first time that it becomes necessary after starting the server (eg INSERT), selecting the maximum value that exists on the table is incremented by 1. At that point the value is stored in memory but not written to disk, so the next reboot will be recalculated. This means that if you delete the last values of the table without making new entries, restart the server to reuse those values. With InnoDB tables we can define the foreign key, or connecting the values of the columns that contain keys to other tables to the tables. In this way you can check automatically when the values of the parent table is modified or removed so as to prevent these changes or, conversely, to amend the values on the child table. Also you can not enter values in the child table that have no counterpart in the parent table. Let's see an example definition:
Code:
CREATE TABLE parent (id INT NOT NULL,
PRIMARY KEY (id)
) ENGINE = INNODB;
CREATE TABLE child (id INT, INT mother_id,
INDEX par_ind (mother_id)
FOREIGN KEY (mother_id) REFERENCES parent (id)
ON DELETE CASCADE
) ENGINE = INNODB;
This code defines two tables where we see the child table has a foreign key on the parent table. When deleting a row from parent table if the value of id is present in a field mother_id daughter of the table the row is also deleted. Both tables must be InnoDB type, both columns must appear as the first field of an index. You can name the report stating "CONSTRAINT name FOREIGN KEY before. This name will then be used if you decide to delete the foreign key, with the syntax "ALTER TABLE table DROP FOREIGN KEY name". If the name is not specified, will be created automatically by the server and view it through "SHOW CREATE TABLE table". In the example we saw an indication of the ON DELETE clause to handle cancellations on the foreign key referenced, so it is possible to use ON UPDATE to manage updates. Both options accept as one of the following possible values: CASCADE, SET NULL, RESTRICT, NO ACTION.
With the former, as we have seen, the changes on the parent table are reported on the child table. With SET NULL values in any child table are set to NULL (the definition of the column should allow). The last two are equivalent to omit the clause, leading to the rejection of the amendment on the parent table. In a table, InnoDB is not possible to use FULLTEXT indexes, and columns of geometric type are only available since version 5.0.16. For AUTO_INCREMENT columns must exist an index of which they are the only component.
Bookmarks