mysql连接查询建表数据(为小例题服务)

例题1:

create table teams(
 id int unsigned primary key auto_increment,
 t_id  int unsigned not null,
 t_name varchar(10) 
 )engine innodb character set utf8;
insert into teams(t_id,t_name)
values
(2,'火箭'),
(1,'小牛'),
(4,'湖人'),
(3,'热火'),
(5,'拜仁')
;
 create table result(
 id int primary key auto_increment,
 h_id int not null,
 g_id int not null,
 match_time datetime not null,
 result varchar(20) not null
 )engine innodb character set utf8;

 insert into result
 (h_id,g_id,match_time,result)
 values
 (2,4,'2014-1-23 08:00:00','38:55'),
 (3,4,'2014-1-10 09:00:00','27:22'),
 (2,5,'2014-2-2  10:10:00','33:49'),
 (5,1,'2014-2-6 14:00:00','22:26'),
 (3,5,'2014-2-18 15:30:00','44:38');

 例题2:

DROP TABLE IF EXISTS `subject`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `subject` (
  `id` int(10) unsigned NOT NULL,
  `pid` int(10) unsigned DEFAULT NULL,
  `name` varchar(10) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `subject`
--

LOCK TABLES `subject` WRITE;
/*!40000 ALTER TABLE `subject` DISABLE KEYS */;
INSERT INTO `subject` VALUES (1,9,'脚本语言'),(2,9,'编译语言'),(3,1,'php'),(4,1,'js'),(5,1,'python'),(6,2,'C'),(7,2,'C++'),(8,2,'Java'),(9,0,'编程语言');
/*!40000 ALTER TABLE `subject` ENABLE KEYS */;
UNLOCK TABLES;

 

posted @ 2014-03-06 20:54  H&K  阅读(446)  评论(0编辑  收藏  举报