Table of Contents
数据表的可移植性
Home Database Mysql Tutorial mysql数据表六种类型_MySQL

mysql数据表六种类型_MySQL

Jun 01, 2016 pm 01:10 PM

MySQL 数据表主要支持六种类型 ,分别是:BDB、HEAP、ISAM、MERGE、MYISAM、InnoBDB。

这六种又分为两类,一类是”事务安全型”(transaction-safe),包括BDB和InnoDB;其余都属于第二类,称为”非事务安全型”(non-transaction-safe)。

BDB 全称是”Brekeley DB”,它是Mysql最早的具有事务能力的表的类型,由Sleepycat Software (http://www.sleepycat.com)开发。它提供了事务控制能力功能,它确保一组命令全部执行成功,或者当任何一个命令出现错误时所有 命令的结果都被回退,可以想像在电子银行中事务控制能力是非常重要的。支持COMMIT、ROLLBACK和其他事务特性。最新版本的Mysql已经计划 移除对BDB的支持,转而全力发展InnoDB。

InnoDB 是较新的事务安全型存储引擎,用于事务处理应用程序,支持BDB的几乎所有特性,并具有众多新特性,包括ACID事务支持。

特性:

  • 事务处理机制

  • 支持外链

  • 崩溃后能立即恢复

  • 支持外键功能,级联删除

  • 支持并发能力

  • 在硬盘上的存储方式:InnoBDB frm

最新版本的Mysql已经计划移除对BDB的支持,转而全力发展InnoDB。InnoDB对Mysql有更好的特性支持,而且开发社区活跃。

MyISAM 默认的MySQL插件式存储引擎,它是基于ISAM类型,但它增加了许多有用的扩展,它是在Web、数据仓储和其他应用环境下最常使用的存储引擎之一。注意,通过更改STORAGE_ENGINE配置变量,能够方便地更改MySQL服务器的默认存储引擎。
优点:

  • 1.比ISAM表更小,所占资源更少

  • 2.可以在不同平台间二进制移植表的类型在创建表时指定。

ISAM 是MyISAM类型出现之前MySQL表使用的默认类型,现在已经被MyISAM代替。

Memory (HEAP) 是MySQL表中访问最快的表,将所有数据保存在RAM中,在需要快速查找引用和其他类似数据的环境下,可提供极快的访问。注意,这种类型下数据是非持久化设计的,它一般适应于临时表,如果MySQL或者服务器崩溃,表中数据全部丢失。

Merge 是一种值得关注的新式表,它是由一组MyISAM表组成,之所合并主要出于性能上考虑,因为它能够提高搜索速度,提高修复效率,节省磁盘空 间。允许MySQL DBA或开发人员将一系列等同的MyISAM表以逻辑方式组合在一起,并作为1个对象引用它们。对于诸如数据仓储等VLDB环境十分适合。有时它以 MRG_MYISAM 名称出现。

Archive 为大量很少引用的历史、归档、或安全审计信息的存储和检索提供了完美的解决方案。

Federated 能够将多个分离的MySQL服务器链接起来,从多个物理服务器创建一个逻辑数据库。十分适合于分布式环境或数据集市环境。

NDBCluster/Cluster/NDB MySQL的簇式数据库引擎,尤其适合于具有高性能查找要求的应用程序,这类查找需求还要求具有最高的正常工作时间和可用性。

CSV 使用标准的CSV格式,由逗号隔开的文本文件,适应于外部数据交换

Blackhole 它会接受数据但不保存,而且对任何检索请求返回一个空集。它一般适应于数据会被自动复制并不进行本地保存的分布式数据库设计。(不确定的)似乎也可以用于临时禁止/忽略对数据库的应用程序输入。

Example 这是一个测试引擎,你可以创建一个这样的表,但既不能写入数据,也不能检索数据。它似乎是一个针对MySql开发者提供的示例引擎。

有关操作和查看表类型的命令语法如下

?[Copy to clipboard]View Code SQL

123456789101112131415161718192021222324
Copy after login
---- 创建表时指定表类型的方法CREATE TABLE `message` (`id` int(11) NOT NULL auto_increment,`sender` varchar(255) default NULL,`receiver` varchar(255) default NULL,`content` text,`is_read` char(1) default 'N',`send_time` datetime default NULL,`del_flag` tinyint(4) default '0',PRIMARY KEY (`id`)) ENGINE=MYISAM; -- 也可以创建后更改:ALTER TABLE `message` ENGINE = INNODB; -- 查看表类型(存储引擎)SHOW TABLE STATUS FROM `test`;-- -- 结果为数据库test中所有表的信息,其中第二项type即是表的类型。 -- 查看表类型(存储引擎)2SHOW CREATE TABLE `message`;-- -- 结果为表message创建时的信息,其中有TYPE或ENGINE一项,指定了表的类型(存储引擎)。-- show tables不能得到表类型的信息。
Copy after login

注意:老版本的MySQL使用 TYPE而不是ENGINE(例如,TYPE = MYISAM)。MySQL 5.1为向下兼容而支持这个语法,但TYPE现在被轻视,而ENGINE 是首先的用法。 一般地,ENGINE选项是不必要的;除非默认已经被改变了,MyISAM是默认存储引擎。

数据表的可移植性

常用的数据移植方法:把数据表的内容导出到一个文本文件中,然后拷贝到硬盘上,然后导入目标数据库里面。

就文件层次的操作来说,某些数据表是可以直接单独拷贝表文件来移动的,见下表

ISAM No
MyIASM Yes
BDB No
InnoBDB Yes


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

When might a full table scan be faster than using an index in MySQL? When might a full table scan be faster than using an index in MySQL? Apr 09, 2025 am 12:05 AM

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Explain InnoDB Full-Text Search capabilities. Explain InnoDB Full-Text Search capabilities. Apr 02, 2025 pm 06:09 PM

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

Can I install mysql on Windows 7 Can I install mysql on Windows 7 Apr 08, 2025 pm 03:21 PM

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

Difference between clustered index and non-clustered index (secondary index) in InnoDB. Difference between clustered index and non-clustered index (secondary index) in InnoDB. Apr 02, 2025 pm 06:25 PM

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values ​​and pointers to data rows, and is suitable for non-primary key column queries.

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

How do you handle large datasets in MySQL? How do you handle large datasets in MySQL? Mar 21, 2025 pm 12:15 PM

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

The relationship between mysql user and database The relationship between mysql user and database Apr 08, 2025 pm 07:15 PM

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

See all articles