日期:2014-05-16  浏览次数:20994 次

mysql 删除当前数据库下所有表
hibernate 自动建立的表,都引用了一些外键,现在没用了,想全部删掉,怎么办,坐等解答.谢谢

------解决方案--------------------
这是我写的一段代码,很好用的,你看看能不能用。。
set names utf8; 
create database jol;
use jol;

CREATE TABLE `compileinfo` (
`solution_id` int(11) NOT NULL DEFAULT '0',
`error` text,
PRIMARY KEY (`solution_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


CREATE TABLE `contest` (
`contest_id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) DEFAULT NULL,
`start_time` datetime DEFAULT NULL,
`end_time` datetime DEFAULT NULL,
`defunct` char(1) NOT NULL DEFAULT 'N',
`description` text,
`private` tinyint(4) NOT NULL DEFAULT '0',
`langmask` int NOT NULL DEFAULT '0' COMMENT 'bits for LANG to mask',
PRIMARY KEY (`contest_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8;

CREATE TABLE `contest_problem` (
`problem_id` int(11) NOT NULL DEFAULT '0',
`contest_id` int(11) DEFAULT NULL,
`title` char(200) NOT NULL DEFAULT '',
`num` int(11) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


CREATE TABLE `loginlog` (
`user_id` varchar(20) NOT NULL DEFAULT '',
`password` varchar(40) DEFAULT NULL,
`ip` varchar(100) DEFAULT NULL,
`time` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `mail` (
`mail_id` int(11) NOT NULL AUTO_INCREMENT,
`to_user` varchar(20) NOT NULL DEFAULT '',
`from_user` varchar(20) NOT NULL DEFAULT '',
`title` varchar(200) NOT NULL DEFAULT '',
`content` text,
`new_mail` tinyint(1) NOT NULL DEFAULT '1',
`reply` tinyint(4) DEFAULT '0',
`in_date` datetime DEFAULT NULL,
`defunct` char(1) NOT NULL DEFAULT 'N',
PRIMARY KEY (`mail_id`),
KEY `uid` (`to_user`)
) ENGINE=MyISAM AUTO_INCREMENT=1013 DEFAULT CHARSET=utf8;

CREATE TABLE `news` (
`news_id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` varchar(20) NOT NULL DEFAULT '',
`title` varchar(200) NOT NULL DEFAULT '',
`content` text NOT NULL,
`time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`importance` tinyint(4) NOT NULL DEFAULT '0',
`defunct` char(1) NOT NULL DEFAULT 'N',
PRIMARY KEY (`news_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1004 DEFAULT CHARSET=utf8;


CREATE TABLE `privilege` (
`user_id` char(20) NOT NULL DEFAULT '',
`rightstr` char(30) NOT NULL DEFAULT '',
`defunct` char(1) NOT NULL DEFAULT 'N'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `problem` (
`problem_id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(200) NOT NULL DEFAULT '',
`description` text,
`input` text,
`output` text,
`sample_input` text,
`sample_output` text,
`spj` char(1) NOT NULL DEFAULT '0',
`hint` text,
`source` varchar(100) DEFAULT NULL,
`in_date` datetime DEFAULT NULL,
`time_limit` int(11) NOT NULL DEFAULT '0',
`memory_limit` int(11) NOT NULL DEFAULT '0',
`defunct` char(1) NOT NULL DEFAULT 'N',
`accepted` int(11) DEFAULT '0',
`submit` int(11) DEFAULT '0',
`solved` int(11) DEFAULT '0',
PRIMARY KEY (`problem_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1001 DEFAULT CHARSET=utf8;

CREATE TABLE `reply` (
`rid` int(11) NOT NULL AUTO_INCREMENT,
`author_id` varchar(20) NOT NULL,
`time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`content` text NOT NULL,
`topic_id` int(11) NOT NULL,
`status` int(2) NOT NULL DEFAULT '0',
`ip` varchar(30) NOT NULL,
PRIMARY KEY (`rid`),
KEY `author_id` (`author_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;



------解决方案--------------------
直接 drop database db1;
然后再重新 cr