首页 > 数据库技术 > 详细

Mysql:查用的基本操作

时间:2017-04-15 01:13:52      阅读:204      评论:0      收藏:0      [点我收藏+]


查看MySQL提供什么存储引擎:

mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+

查看MySQL当前默认的存储引擎:

mysql> show variables like %storage_engine%;
+----------------------------------+--------+
| Variable_name                    | Value  |
+----------------------------------+--------+
| default_storage_engine           | InnoDB |
| default_tmp_storage_engine       | InnoDB |
| disabled_storage_engines         |        |
| internal_tmp_disk_storage_engine | InnoDB |
+----------------------------------+--------+
4 rows in set, 1 warning (0.01 sec)

创建表:

mysql> create table NEWS (
    ->        ID integer not null auto_increment,
    ->         AUTHOR varchar(255),
    ->         CONTENT varchar(255),
    ->         CREATEDATE datetime,
    ->         primary key (ID)
    ->     ) ;
Query OK, 0 rows affected (0.04 sec)

 

你要看 news 表用了什么引擎(在显示结果里参数engine后面的就表示该表当前用的存储引擎):

mysql> show create table news;
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table     |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| news  | CREATE TABLE `news` (
              `ID` int(11) NOT NULL AUTO_INCREMENT,
              `AUTHOR` varchar(255) DEFAULT NULL,
              `CONTENT` varchar(255) DEFAULT NULL,
              `CREATEDATE` datetime DEFAULT NULL,
              PRIMARY KEY (`ID`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

 

将 news 表修为InnoDB存储引擎(也可以此命令将InnoDB换为MyISAM):

mysql> ALTER TABLE news ENGINE=INNODB;

 

Mysql:查用的基本操作

原文:http://www.cnblogs.com/yy3b2007com/p/6711547.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!