61MySQL权威开发指南

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

MySQL开发者SQL权威指南SQLForMySQLDevelopersAComprehensiveTutorialandReference整理:侯杰MySQL开发范例-1-第一章SQL概要1.引入一个名为BOOKSQL的新用户,他的密码是BOOKSQLPW。CREATEUSER‘BOOKSQL’@’LOCALHOST’IDENTIFIEDBY‘BOOKSQLPW’createuser‘houjie410782’@’localhost’identifiedby‘630529’2.给SQL用户BOOKSQL创建和操作表的权限。grantallprivilegeson*.*to‘BOOKSQL’@’LOCALHOST’withgrantoption;gratallprivilegeson*.*to‘houjie410782’@’localhost’withgrantoption;3.创建数据库tennis。createdatabasetennis;4.指定tennis为当前数据库。usetennis;5.创建表players,teams,matches,penalties,committee_members。createtableplayers(playernointegernotnull,namechar(15)notnull,initialschar(3)notnull,birth_datedate,sexchar(1)notnull,joinedsmallintnotnull,streetvarchar(30)notnull,housenochar(4),postcodechar(6),townvarchar(30)notnull,phonenochar(13),leaguenochar(4),primarykey(playerno))createtableteams(teamnointegernotnull,playernointegernotnull,divisionchar(6)notnull,primarykey(teamno))createtablematches(matchnointegernotnull,teamnointegernotnull,playernointegernotnull,wonsmallintnotnull,lostsmallintnotnull,primarykey(matchno))createtablepenalties(paymentnointegernotnull,playernointegernotnull,payment_datedatenotnull,amountdecimal(7,2)notnull,primarykey(paymentno)MySQL开发范例-2-)createtablecommittee_members(playernointegernotnull,begin_datedatenotnull,end_datedate,positionchar(20),primarykey(playerno,begin_date))6.为表中填充数据。insertintoplayersvalues(2,'Everett','R','1948-09-01','M',1975,'StoneyRoad','43','3575NH','Stratford','070-237893','2411');insertintoplayersvalues(7,'Wise','GWS','1963-05-11','M',1981,'EdgecombeWay','39','9758VB','Stratford','070-347689',NULL);insertintoplayersvalues(8,'NewCastle','B','1962-07-08','F',1980,'StationRoad','4','6584R0','Inglewood','070-458458','2983');insertintoplayersvalues(27,'Collins','DD','1964-12-28','F',1983,'LongDrive','804','8457DK','Eltham','079-234857','2513');insertintoplayersvalues(28,'Collins','C','1963-06-22','F',1983,'OldMianRoad','10','1294QK','Midhurst','071-659599',NULL);insertintoplayersvalues(39,'Bishop','D','1956-10-29','M',1980,'EatonSquare','78','9629CD','Stratford','070-393435',NULL);insertintoplayersvalues(44,'Baker','E','1963-01-09','M',1980,'LewisStreet','23','4444LJ','Inglewood','070-368753','1124');insertintoplayersvalues(57,'Brown','M','1971-08-17','M',1985,'EdgecombeWay','16','4377CB','Stratford','070-473458','6409');insertintoplayersvalues(83,'Hope','PK','1956-11-11','M',1982,'MagdaleneRoad','16A','1812UP','Stratford','070-353548','1608');insertintoplayersvalues(95,'Miller','P','1963-05-14','M',1972,'HighStreet','33A','5746OP','Douglas','070-867564',NULL);insertintoplayersvalues(100,'Parmanter','P','1963-02-28','M',1979,'HaseltineLane','80','1234KK','Stratford','070-494593','6524');insertintoplayersvalues(104,'Moorman','D','1970-05-10','F',1984,'StoutStreet','65','9437A0','Eltham','079-987571','7060');insertintoplayersvalues(112,'Bailey','IP','1963-10-01','F',1984,'VixenRoad','8','6392LK','Plymouth','010-548745','1319');insertintoplayersvalues(6,'parmenter','R','1964-06-25','M',1977,'HaseltineLane','80','1234KK','Stratford','070-476537','8467');insertintoteamsvalues(1,6,'first');insertintoteamsvalues(2,27,'second');insertintomatchesvalues(1,1,6,3,1);insertintomatchesvalues(2,1,6,2,3);insertintomatchesvalues(3,1,6,3,0);insertintomatchesvalues(4,1,44,3,2);insertintomatchesvalues(5,1,83,0,3);insertintomatchesvalues(6,1,2,1,3);insertintomatchesvalues(7,1,2,1,3);insertintomatchesvalues(8,1,8,0,3);insertintomatchesvalues(9,2,27,3,2);MySQL开发范例-3-insertintomatchesvalues(10,2,104,3,2);insertintomatchesvalues(11,2,112,2,3);insertintomatchesvalues(12,2,112,1,3);insertintomatchesvalues(13,2,8,0,3);insertintopenaltiesvalues(1,6,'1980-12-08',100.00);insertintopenaltiesvalues(2,44,'1981-05-05',75.00);insertintopenaltiesvalues(3,27,'1983-09-10',100.00);insertintopenaltiesvalues(4,104,'1984-12-08',50.00);insertintopenaltiesvalues(5,44,'1980-12-08',25.00);insertintopenaltiesvalues(6,8,'1980-12-08',25.00);insertintopenaltiesvalues(7,44,'1982-12-30',30.00);insertintopenaltiesvalues(8,27,'1984-11-12',75.00);insertintocommittee_membersvalues(2,'1990-01-01','1992-12-31','Chairman');insertintocommittee_membersvalues(2,'1994-01-01',NULL,'Member');insertintocommittee_membersvalues(6,'1990-01-01','1990-12-31','Secretary');insertintocommittee_membersvalues(6,'1991-01-01','1992-12-31','Member');insertintocommittee_membersvalues(6,'1992-01-01','1993-12-31','Treasurer');insertintocommittee_membersvalues(6,'1993-01-01',NULL,'Chairman');insertintocommittee_membersvalues(8,'1990-01-01','1990-12-31','Treasurer');insertintocommittee_membersvalues(8,'1991-01-01','1991-12-31','Secretary');insertintocommittee_membersvalues(8,'1993-01-01','1993-12-31','Member');insertintocommittee_membersvalues(8,'1994-01-01',NULL,'Member');insertintocommittee_membersvalues(27,'1990-01-01','1990-12-31','Member');insertintocommittee_membersvalues(27,'1991-01-01','1991-12-31','Treasurer');insertintocommittee_membersvalues(27,'1993-01-01','1993-12-31','Treasurer');insertintocommittee_membersvalues(57,'1992-01-01','1992-1

1 / 45
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功