年末整理八 引擎MYSQL

显示引擎的命令得到一个可用引擎的列表
show engines


安装mysql的时候可以选择使用myisam格式,而并非默认的innoDB.
如果想在已经安装好了的mysql服务器上更改默认的存储引擎,则按照下面的方法操作。
可以在MySQL设置文件中设置一个默认的引擎类型(使用storage_engine 选项)或者在启动数据库服务器时在命令行后面加上--default-storage-engine或--default-table-type选项

如果是创建表
create table buygoods (i int, c char(20)) type = myisam
如果是修改表存储引擎
alter table buygoods type = myisam
alter table buygoods engine = myisam


下述存储引擎是最常用的:

◆ MyISAM:默认的MySQL插件式存储引擎,它是在Web、数据仓储和其他应用环境下最常使用的存储引擎之一。
注意,通过更改STORAGE_ENGINE配置变量,能够方便地更改MySQL服务器的默认存储引擎。

◆ InnoDB:用于事务处理应用程序,具有众多特性,包括ACID事务支持。

◆ BDB:可替代InnoDB的事务引擎,支持COMMIT、ROLLBACK和其他事务特性。

◆ Memory:将所有数据保存在RAM中,在需要快速查找引用和其他类似数据的环境下,可提供极快的访问。

◆ Merge:允许MySQL DBA或开发人员将一系列等同的MyISAM表以逻辑方式组合在一起,并作为1个对象引用它们。对于诸如数据仓储等VLDB环境十分适合。

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

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

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

◆ Other:其他存储引擎包括CSV(引用由逗号隔开的用作数据库表的文件),Blackhole(用于临时禁止对数据库的应用程序输入),以及Example引擎(可为快速创建定制的插件式存储引擎提供帮助)。

请记住,对于整个服务器或方案,你并不一定要使用相同的存储引擎,你可以为方案中的每个表使用不同的存储引擎,这点很重要。

 

setting the storage engines:
1.创建表时可指定表的存储引擎:CREATE TABLE t (i INT) ENGINE = INNODB;
2.创建表时省略engine=‘’,,使用my.cnf中的default-engine : (my.ini中) default-storage-engine=innodb
3.在mysql session中使用SET storage_engine=MYISAM 命令来改变数据库的 当前default-storage-engine
4.改变表的存储引擎:ALTER TABLE t ENGINE = MYISAM;
5. 摘要:
A database may contain tables of different types
This automatic substitution of the default storage engine for unavailable engines can be confusing for new MySQL users.
A warning is generated whenever a storage engine is automatically changed.

##########################################################################################
2010-1-6  innodb configuration :
1. using the per-table tablespaces
You can store each InnoDB table and its indexes in its own file. This feature is called “multiple tablespaces” .
To enable multiple tablespaces, start the server with the --innodb_file_per_table option
在my.cnf配置中必须配置参数:
[mysqld]
innodb_file_per_table

With multiple tablespaces enabled,
InnoDB stores each newly created table into its own tbl_name.ibd file in the database directory
where the table belongs.
This is similar to what the MyISAM storage engine does,
but MyISAM divides the table into a tbl_name.MYD data file and an tbl_name.MYI index file.
For InnoDB, the data and the indexes are stored together in the .ibd file.
The tbl_name.frm file is still created as usual.
(innodb的Per-table,各表的内容和索引存储在tname.idb文件中,而myisam引擎的各表的内容存储在tname.MYD,索引存储在tname.MYI中)

2. using Raw Devices for the shared tablespace


When you create a new data file,
you must put the keyword newraw immediately after the data file size in innodb_data_file_path.
The next time you start the server,
InnoDB notices the newraw keyword and initializes the new partition。
However, do not create or change any InnoDB tables yet.
After InnoDB has initialized the new partition,
stop the server, change newraw in the data file specification to raw:
新添加一个datafile存放表空间时, 在size后紧加newraw ,重启mysql后,innodb捕获关键字newraw并初始化新的partition,
在innodb初始化partition后,stop mysql服务,改newraw为raw,,启动mysql服务。

[mysqld]
innodb_data_home_dir=
innodb_data_file_path=/dev/hdd1:3Gnewraw;/dev/hdd2:2Gnewraw

[mysqld]
innodb_data_home_dir=
innodb_data_file_path=/dev/hdd1:3Graw;/dev/hdd2:2Graw

On Windows, you can allocate a disk partition as a data file like this:
[mysqld]
innodb_data_home_dir=
innodb_data_file_path=//./D::10Gnewraw

3. creating the innodb tablespace
4. Dealing with InnoDB Initialization Problems

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值