方法:

show create table 旧表;
这样会将旧表的创建命令列出。我们只需要将该命令拷贝出来,更改table的名字,就可以建立一个完全一样的表

 

 

CREATE TABLE `tw_drafts_1` (
`mid` tinyint(1) unsigned NOT NULL DEFAULT ‘0’,
`cid` smallint(5) unsigned NOT NULL DEFAULT ‘0’,
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` char(80) NOT NULL DEFAULT ”,
`color` char(6) NOT NULL DEFAULT ”,
`alias` char(50) NOT NULL DEFAULT ”,
`tags` varchar(255) NOT NULL DEFAULT ”,
`intro` varchar(255) NOT NULL DEFAULT ”,
`pic` varchar(255) NOT NULL DEFAULT ”,
`uid` int(10) unsigned NOT NULL DEFAULT ‘0’,
`author` varchar(20) NOT NULL DEFAULT ”,
`source` varchar(150) NOT NULL DEFAULT ”,
`dateline` int(10) unsigned NOT NULL DEFAULT ‘0’,
`lasttime` int(10) unsigned NOT NULL DEFAULT ‘0’,
`ip` int(10) NOT NULL DEFAULT ‘0’,
`iscomment` tinyint(1) unsigned NOT NULL DEFAULT ‘0’,
`views` int(10) unsigned NOT NULL DEFAULT ‘0’,
`imagenum` int(10) unsigned NOT NULL DEFAULT ‘0’,
`flags` varchar(20) NOT NULL DEFAULT ”,
`seo_title` varchar(80) NOT NULL DEFAULT ”,
`seo_keywords` varchar(80) NOT NULL DEFAULT ”,
`seo_description` varchar(255) NOT NULL DEFAULT ”,
`content` mediumtext NOT NULL,
`images` mediumtext NOT NULL,
`push` tinyint(1) unsigned NOT NULL DEFAULT ‘0’,
`oprice` double(10,2) NOT NULL DEFAULT ‘0.00’,
`pay_content` text NOT NULL,
PRIMARY KEY (`id`),
KEY `cid_id` (`cid`,`id`),
KEY `cid_dateline` (`cid`,`dateline`)
) ENGINE=MyISAM AUTO_INCREMENT=3261166 DEFAULT CHARSET=utf8

 

 

另,数据库修改表名:

RENAME TABLE tw_drafts TO tw_drafts_6;
RENAME TABLE tw_drafts_7 TO tw_drafts;

共有 0 条评论