|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
BlackHole黑洞引擎,写入的任何数据都会消失,一般用于记录binlog做复制的中继语句申明:复制表(只复制布局,源表名:a新表名:b)
SQL:select*intobfromawhere11
申明:拷贝表(拷贝数据,源表名:a方针表名:b)
SQL:insertintob(a,b,c)selectd,e,ffromb;
申明:显现文章、提交人和最初复兴工夫
SQL:selecta.title,a.username,b.adddatefromtablea,(selectmax(adddate)adddatefromtablewheretable.title=a.title)b
申明:外毗连查询(表名1:a表名2:b)
SQL:selecta.a,a.b,a.c,b.c,b.d,b.ffromaLEFTOUTJOINbONa.a=b.c
申明:日程布置提早五分钟提示
SQL:select*from日程布置wheredatediff(minute,f入手下手工夫,getdate())>5
申明:两张联系关系表,删除主表中已在副表中没有的信息
SQL:
deletefrominfowherenotexists(select*frominfobzwhereinfo.infid=infobz.infid)
申明:--
SQL:
SELECTA.NUM,A.NAME,B.UPD_DATE,B.PREV_UPD_DATEFROMTABLE1,(SELECTX.NUM,X.UPD_DATE,Y.UPD_DATEPREV_UPD_DATEFROM(SELECTNUM,UPD_DATE,INBOUND_QTY,STOCK_ONHANDFROMTABLE2WHERETO_CHAR(UPD_DATE,YYYY/MM)=TO_CHAR(SYSDATE,YYYY/MM))X,(SELECTNUM,UPD_DATE,STOCK_ONHANDFROMTABLE2WHERETO_CHAR(UPD_DATE,YYYY/MM)=TO_CHAR(TO_DATE(TO_CHAR(SYSDATE,YYYY/MM)¦¦/01,YYYY/MM/DD)-1,YYYY/MM))Y,WHEREX.NUM=Y.NUM(+)ANDX.INBOUND_QTY+NVL(Y.STOCK_ONHAND,0)X.STOCK_ONHAND)BWHEREA.NUM=B.NUM
申明:--
SQL:
select*fromstudentinfowherenotexists(select*fromstudentwherestudentinfo.id=student.id)and系称号="&strdepartmentname&"and专业称号="&strprofessionname&"orderby性别,生源地,高考总成就
申明:从数据库中往一年的各单元德律风费统计(德律风费定额贺电化肥清单两个表来历)
SQL:
SELECTa.userper,a.tel,a.standfee,TO_CHAR(a.telfeedate,yyyy)AStelyear,SUM(decode(TO_CHAR(a.telfeedate,mm),01,a.factration))ASJAN,SUM(decode(TO_CHAR(a.telfeedate,mm),02,a.factration))ASFRI,SUM(decode(TO_CHAR(a.telfeedate,mm),03,a.factration))ASMAR,SUM(decode(TO_CHAR(a.telfeedate,mm),04,a.factration))ASAPR,SUM(decode(TO_CHAR(a.telfeedate,mm),05,a.factration))ASMAY,SUM(decode(TO_CHAR(a.telfeedate,mm),06,a.factration))ASJUE,SUM(decode(TO_CHAR(a.telfeedate,mm),07,a.factration))ASJUL,SUM(decode(TO_CHAR(a.telfeedate,mm),08,a.factration))ASAGU,SUM(decode(TO_CHAR(a.telfeedate,mm),09,a.factration))ASSEP,SUM(decode(TO_CHAR(a.telfeedate,mm),10,a.factration))ASOCT,SUM(decode(TO_CHAR(a.telfeedate,mm),11,a.factration))ASNOV,SUM(decode(TO_CHAR(a.telfeedate,mm),12,a.factration))ASDECFROM(SELECTa.userper,a.tel,a.standfee,b.telfeedate,b.factrationFROMTELFEESTANDa,TELFEEbWHEREa.tel=b.telfax)aGROUPBYa.userper,a.tel,a.standfee,TO_CHAR(a.telfeedate,yyyy)
申明:四表联查询题:
SQL:select*fromaleftinnerjoinbona.a=b.brightinnerjoincona.a=c.cinnerjoindona.a=d.dwhere.....
申明:失掉表中最小的未利用的ID号
SQL:
SELECT(CASEWHENEXISTS(SELECT*FROMHandlebWHEREb.HandleID=1)THENMIN(HandleID)+1ELSE1END)asHandleIDFROMHandleWHERENOTHandleIDIN(SELECTa.HandleID-1FROMHandlea)
索引是一种特殊的文件(InnoDB数据表上的索引是表空间的一个组成部分),它们包含着对数据表里所有记录的引用指针。索引不是万能的,索引可以加快数据检索操作,但会使数据修改操作变慢。每修改数据记录,索引就必须刷新一次。 |
|