您好,登錄后才能下訂單哦!
mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES
查看 MySQL 支持的引擎以及默認存儲引擎 。
show table status from 庫名 where name='表名';
mysql> show table status from jdy where name='test';
+------+--------+---------+------------+------+
| Name | Engine | Version | Row_format | Rows |
+------+-------------+-----------------+--------------+
| test | InnoDB | 10 | Dynamic | 0 | # 表的存儲引擎 InnoDB
show create table 表名;
mysql> use jdy; # 進入查看表的數據庫
Database changed
mysql> show create table test;
+-------+---------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+---------------------------------------------------------------------------------------------------------------------------+
| test | CREATE TABLE "test" (
"name" varchar(10) DEFAULT NULL,
"id" int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 | # 表的存儲引擎 InnoDB
mysql> use jdy; # 進入查看表的數據庫
Database changed
mysql> show create table test;
+-------+---------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+---------------------------------------------------------------------------------------------------------------------------+
| test | CREATE TABLE "test" (
"name" varchar(10) DEFAULT NULL,
"id" int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 | # 表的存儲引擎 InnoDB
#命令: alter table 表名 engine=引擎;
mysql> alter table test engine=MyISAM; #修改表的存儲引擎為 MyISAM
Query OK, 0 rows affected (0.39 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table test;
+-------+---------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+---------------------------------------------------------------------------------------------------------------------------+
| test | CREATE TABLE "test" (
"name" varchar(10) DEFAULT NULL,
"id" int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 | #修改成功
vim /etc/my.cnf
[mysqld]
default-storage-engine=MyISAM #添加指定默認存儲引擎
mysql> create table test01 (id int ); #創建表
Query OK, 0 rows affected (0.00 sec)
mysql> show create table test01;
+--------+------------------------------------------------------------------------------------------+
| Table | Create Table |
+--------+------------------------------------------------------------------------------------------+
| test01 | CREATE TABLE "test01" (
"id" int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 | #創建的新表默認 MyISAM
設置默認存儲引擎 ,創建的新表將使用 MyISAM 存儲引擎 。
mysql> create table test02 (id int ) engine=InnoDB;
Query OK, 0 rows affected (0.35 sec)
mysql> show create table test02;
+--------+------------------------------------------------------------------------------------------+
| Table | Create Table |
+--------+------------------------------------------------------------------------------------------+
| test02 | CREATE TABLE "test02" (
"id" int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 | #新表存儲引擎是 InnoDB
[root@localhost ~]#mysql_convert_table_format --host=localhost --user=root --password=abc123 --socket=/tmp/mysql.scok --engine=InnoDB jdy test01 test02
yum install perl perl-DBD-MySQL -y
vim /usr/local/mysql/bin/mysql_convert_table_format #修改命令腳本
$opt_help=$opt_version=$opt_verbose=$opt_force=0;
$opt_user=$opt_database=$opt_password=undef;
$opt_host="localhost";
$opt_socket="";
$opt_engine="MYISAM";
$opt_port=0;
$exit_status=0;
GetOptions(
"e|engine|type=s" => \$opt_type, #把type修改成engine
"f|force" => \$opt_force,
"help|?" => \$opt_help,
"h|host=s" => \$opt_host,
"p|password=s" => \$opt_password,
"u|user=s" => \$opt_user,
"v|verbose" => \$opt_verbose,
"V|version" => \$opt_version,
"S|socket=s" => \$opt_socket,
"P|port=i" => \$opt_port
) || usage(0);
ps: 第四種方法只適合MySQL 5.5版本 。MySQL 5.5 默認存儲引擎MyISAM 5.7 默認存儲引擎 InnoDB。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。