创建数据库

时间:2015-12-14 13:36:22
【文件属性】:

文件名称:创建数据库

文件大小:4KB

文件格式:SQL

更新时间:2015-12-14 13:36:22

sql

/* SQLyog 企业版 - MySQL GUI v7.14 MySQL - 5.1.30-community : Database - school_db ********************************************************************* */ /*!40101 SET NAMES utf8 */; /*!40101 SET SQL_MODE=''*/; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*Table structure for table `class_m` */ DROP TABLE IF EXISTS `class_m`; CREATE TABLE `class_m` ( `classno` int(11) NOT NULL AUTO_INCREMENT, `classname` varchar(20) DEFAULT NULL, PRIMARY KEY (`classno`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; /*Data for the table `class_m` */ LOCK TABLES `class_m` WRITE; insert into `class_m`(`classno`,`classname`) values (1,'10软件Java'),(2,'11移动开发'),(3,'11软件JAVA'),(4,'09软件技术J'); UNLOCK TABLES; /*Table structure for table `course` */ DROP TABLE IF EXISTS `course`; CREATE TABLE `course` ( `cno` char(4) NOT NULL DEFAULT '', `cname` varchar(50) NOT NULL, `ccredit` int(11) NOT NULL, PRIMARY KEY (`cno`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*Data for the table `course` */ LOCK TABLES `course` WRITE; insert into `course`(`cno`,`cname`,`ccredit`) values ('012','HTML',4),('1','数据库基础',5),('2','数据结构',4),('3','Java面向对象程序设计',3),('4','JavaEE Web编程技术',4),('5','xml',4),('8','java',4); UNLOCK TABLES; /*Table structure for table `sc` */ DROP TABLE IF EXISTS `sc`; CREATE TABLE `sc` ( `sno` char(9) NOT NULL, `cno` char(4) NOT NULL, `grade` int(11) DEFAULT NULL, KEY `sno` (`sno`), KEY `cno` (`cno`), CONSTRAINT `sc_ibfk_1` FOREIGN KEY (`sno`) REFERENCES `student` (`sno`), CONSTRAINT `sc_ibfk_2` FOREIGN KEY (`cno`) REFERENCES `course` (`cno`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*Data for the table `sc` */ LOCK TABLES `sc` WRITE; insert into `sc`(`sno`,`cno`,`grade`) values ('001','1',80),('001','2',88),('001','2',80),('001','1',70),('003','3',70),('0012','1',60); UNLOCK TABLES; /*Table structure for table `student` */ DROP TABLE IF EXISTS `student`; CREATE TABLE `student` ( `sno` char(9) NOT NULL, `sname` varchar(50) DEFAULT NULL, `ssex` char(2) DEFAULT '男', `sage` smallint(6) DEFAULT '20', `classno` int(4) NOT NULL, `s_entrance` datetime DEFAULT NULL, PRIMARY KEY (`sno`), UNIQUE KEY `sname` (`sname`), KEY `FK_student` (`classno`), CONSTRAINT `FK_student` FOREIGN KEY (`classno`) REFERENCES `class_m` (`classno`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*Data for the table `student` */ LOCK TABLES `student` WRITE; insert into `student`(`sno`,`sname`,`ssex`,`sage`,`classno`,`s_entrance`) values ('0004','sandy','女',20,2,'2012-06-06 09:25:53'),('001','高琳','女',23,1,'2011-04-09 00:00:00'),('0012','tom','女',20,3,'2012-06-06 11:34:11'),('002','jojo','男',18,1,'2010-07-08 00:00:00'),('003','张海霞','女',25,1,'2010-03-07 00:00:00'),('008','helen','女',20,1,'2012-06-06 09:39:43'); UNLOCK TABLES; /*Table structure for table `users` */ DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(20) NOT NULL, `password` varchar(20) DEFAULT NULL, `age` int(11) DEFAULT NULL, `address` varchar(20) DEFAULT NULL, `inday` date DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; /*Data for the table `users` */ LOCK TABLES `users` WRITE; insert into `users`(`id`,`name`,`password`,`age`,`address`,`inday`) values (1,'abc','123',18,NULL,NULL); UNLOCK TABLES; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;


网友评论