mysql storage engine and paradigm

Paradigm

Prerequisite knowledge

1. Code

(1) What is a code?
The only thing that can identify a row of data is the code.
For example, your ID number is a code; your name is not a code, because there may be other people in the world calling this name, but your name plus the names of your father and grandfather can basically form a code.
(2) What is the candidate code?
(3) What is the main code

2. Functional dependencies

(1) Complete dependence
(2) Partial dependence
(3) Transitive dependence

engine

1. View the storage engine:

show engines;

2. Type

MySQL provides users with many different storage engines. In MySQL, there is no need to use the same storage engine in the entire server. For specific requirements, a different storage engine can be used for each table. The value of the Support column indicates whether a certain engine can be used: YES indicates that it can be used, NO indicates that it cannot be used, and DEFAULT indicates that the engine is the current default storage engine.
Use the following sql can see the engine to use by default:
show variables like ‘storage_engine’;
several common storage engine:

  • InnoDB storage engine:
    InnoDB is the preferred engine
    for transactional databases . 1. Supports transaction-safe tables (ACID). Other storage engines are non-transaction-safe tables and support row locking and foreign keys. MySQL 5.5 uses the InnoDB storage engine by default.
    2. Support transaction processing, support foreign keys, support crash repair capabilities and concurrency control.
    3. If you need to have relatively high requirements for transaction integrity (such as banks) and concurrency control (such as ticket sales), then choosing InnoDB has great advantages. If you need to update and delete the database frequently, you can also choose InnoDB, because it supports transaction commit and rollback.

  • MyISAM storage engine:
    MyISAM has high insertion and query speed, but it does not support transactions or foreign keys.
    1 MyISAM is based on the ISAM storage engine and extends it. It is one of the most commonly used storage engines in the Web, data warehousing, and other application environments.
    2 Fast data insertion, low space and memory usage. If the table is mainly used to insert new records and read out records, then choosing MyISAM can achieve high processing efficiency. If the application integrity and concurrency requirements are relatively low, it can also be used.

  • MERGE storage engine: The
    Merge storage engine is a combination of a set of MyISAM tables. These MyISAM tables must have exactly the same structure. The merge table itself has no data. You can perform query, update, and delete operations on merge type tables. These operations are actually correct The internal MyISAM table is carried out.

3. Some commands about the storage engine:

  1. View the storage engine of the table:
    Show create table table_name;
    or
    show table status from db_name where name=‘table_name’;
  2. Modify the storage engine sql of the table:
    Alter table table_name type=InnoDB;
    or
    alter table student engine=MyISAM;
  3. Specify the storage engine when creating the table:
    create table test1(id int) engine= MyISAM
    or
vi /etc/my.cnf
[mysqld]
default-storage-engine=INNODB
  1. Or use the command to modify:
    set default_storage_engine=MyISAM

Guess you like

Origin blog.csdn.net/fuzekun/article/details/104430182