語句如下:alter table tableName engine=InnoDB;
用到的表
復制代碼 代碼如下:
CREATE TABLE IF NOT EXISTS `test` (
`id` int(10) NOT NULL auto_increment,
`websitename` varchar(200) character set utf8 NOT NULL,
`websiteurl` varchar(200) character set utf8 NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
第二不就是如果和添加事物:
復制代碼 代碼如下:
<?php
$con = mysql_connect("localhost", "root", "vertrigo");
//開始事務
mysql_db_query("mysqlnew","BEGIN");
$insertSql ="insert into test(websitename,websiteurl)values('','http://www.jb51.net')";//該記錄插入數據庫
mysql_db_query("mysqlnew",$insertSql);
$insertSql ="insert into test(websitename,websiteurl)values('百度','http://www.baidu.com')";//該記錄插入數據庫
mysql_db_query("mysqlnew",$insertSql);
//結束事務事務
mysql_db_query("mysqlnew","COMMIT");
//開始事務
mysql_db_query("mysqlnew","BEGIN");
$insertSql ="insert into test(websitename,websiteurl)values('google','http://www.google.com.hk')";//該記錄不插入數據庫
mysql_db_query("mysqlnew",$insertSql);
//結束事務事務
mysql_db_query("mysqlnew","ROLLBACK");
//開始事務
mysql_db_query("mysqlnew","BEGIN");
$insertSql ="insert into test(websitename,websiteurl)values('bing','http://www.bing.com')";//該記錄不插入數據庫
mysql_db_query("mysqlnew",$insertSql);
?>
插入的數據
id websitename websiteurl
1 http://www.jb51.net
2 百度 http://www.baidu.com