1、修改建表引擎

 
  
  1. [sql] view plaincopyprint?  
  2. mysql> CREATE TABLE test_2(    
  3.     -> name varchar(10),    
  4.     -> year int(10))    
  5.     -> ENGINE=InnoDB;            -->创建表时指定默认引擎     
  6. Query OK, 0 rows affected (0.10 sec)    
  7.     
  8. mysql> show create table test_2\G    
  9. *************************** 1. row ***************************    
  10.        Table: test_2    
  11. Create Table: CREATE TABLE `test_2` (    
  12.   `name` varchar(10) DEFAULT NULL,    
  13.   `year` int(10) DEFAULT NULL    
  14. ENGINE=InnoDB DEFAULT CHARSET=latin1    
  15. 1 row in set (0.00 sec)    
  16.     
  17. mysql>    
  18.     
  19.     
  20. mysql> show tables;    
  21. +------------------+     
  22. | Tables_in_excise |    
  23. +------------------+     
  24. | test1            |    
  25. | test_1           |    
  26. +------------------+     
  27. 2 rows in set (0.00 sec)    
  28.     
  29. mysql> show create table test_1\G    
  30. *************************** 1. row ***************************    
  31.        Table: test_1    
  32. Create Table: CREATE TABLE `test_1` (    
  33.   `name` varchar(20) DEFAULT NULL,    
  34.   `year` int(5) DEFAULT NULL    
  35. ENGINE=MyISAM DEFAULT CHARSET=latin1     --> 默认的表引擎为MyISAM;     
  36. 1 row in set (0.00 sec)    
  37.     
  38. mysql> alter table test_1 type=InnoDB;  -->  修改表的数据引擎;     
  39. Query OK, 0 rows affected, 1 warning (0.11 sec)    
  40. Records: 0  Duplicates: 0  Warnings: 0    
  41.     
  42. mysql> show create table test_1\G    
  43. *************************** 1. row ***************************    
  44.        Table: test_1    
  45. Create Table: CREATE TABLE `test_1` (    
  46.   `name` varchar(20) DEFAULT NULL,    
  47.   `year` int(5) DEFAULT NULL    
  48. ENGINE=InnoDB DEFAULT CHARSET=latin1  --> 显示表的数据引擎已经变为InnoDB;     
  49. 1 row in set (0.00 sec)    
  50.     
  51. mysql> 

2.

 
  
  1. [sql] view plaincopyprint?  
  2. mysql> show engines;   -->  查看MySQL支持引擎        
  3. +------------+---------+------------------------------------------------------------+--------------+------+------------+     
  4. | Engine     | Support | Comment                                                    | Transactions | XA   | Savepoints |    
  5. +------------+---------+------------------------------------------------------------+--------------+------+------------+     
  6. | MRG_MYISAM | YES     | Collection of identical MyISAM tables                      | NO           | NO   | NO         |    
  7. | CSV        | YES     | CSV storage engine                                         | NO           | NO   | NO         |    
  8. | MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance     | NO           | NO   | NO         |    
  9. | InnoDB     | YES     | Supports transactions, row-level locking, and foreign keys | YES          | YES  | YES        |    
  10. | MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables  | NO           | NO   | NO         |    
  11. +------------+---------+------------------------------------------------------------+--------------+------+------------+     
  12. 5 rows in set (0.00 sec)    
  13.     
  14. mysql>