面試題全集由php高級技術群收集2、mysql_第1頁
面試題全集由php高級技術群收集2、mysql_第2頁
面試題全集由php高級技術群收集2、mysql_第3頁
面試題全集由php高級技術群收集2、mysql_第4頁
面試題全集由php高級技術群收集2、mysql_第5頁
已閱讀5頁,還剩10頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

2、如何判斷SQL語句的運行效率?如何優化一個查詢SQL?通過showstatus命令了解各種SQL的執行頻率:exinselect*fromtablewhereid=1000;1:SELECT*FROMorderWHEREYEAR(orderDate)<2008;(慢)SELECT*FROMorderWHEREorderDate<"2008-01-01";(快)2:SELECT*FROMorderWHEREaddtime/7<24;(慢)SELECT*FROMorderWHEREaddtime<24*7;(快)3:SELECT*FROMorderWHEREtitlelikeSELECT*FROMorderWHEREtitle>="good"and3、設定的用戶數量在千萬級,但是活躍用戶的數量只有1%,如何通過優化數據庫提高活躍用戶的速度?4、服務器在運行的過程中,隨著用戶數量的增長,如何通過優化,保證性5、請寫出5個常用的SQL操作關鍵字.5分Select、update/insert/delete/create/6、請列出5個常用的PHP操作MySQL5分int(10)char(16)varchar(16)datetimetext8、有兩張數據表,表user(id,name)記錄了用戶的ID和昵稱,表article(id,uid,title,content,time)記錄了用戶的文章標題.內容和時間,寫一個SQL語句打印出每個用戶的昵稱及其的文章總數。5分S,count(a.id)fromuseru,articleawhereu.id=,count(a.id)fromuseruleftjoinarticleaonu.id=a.uidgroupbyu.id值是多少?(5分)MyISAM:20InnoDB:17 receintoA(id,c1,c2)selectid,c1,c2fromBwhereage>50;updateAa,Bbseta.c1=b.c1,a.c2=b.c2wherea.id=b.idandb.age>50;索引和非索大,大量,大數據量。表的劃分。關聯采用第三范式,集群,主從,(一)創建發布系統,表名為message有如下字段(3分)id文章idtitlecontentcategory_idhits(二)同樣上述發布系統:表comment記錄用戶回復內容,字段如下(4分)comment_id回復ididid,關聯message表中的idcomment_content回復內容文章idselectm.id,m.title,m.hits,count( ment_id)numfrommessagemleftjoincommentconm.id=c.idgroubym.idorderby ent_id)(三)上述內容管理系統,表category(3分)category_idint(4)notnullauto_increment;categroy_namevarchar(40)not$sql=“selectcategory_id,category_namefrom$result=echo“<selectname=’category_id’>”;While($row=mysql_fetch_assoc($result)){echo“<option}echoCategory類別表Category類別表 Pid上一級類別IDName類別名稱Products產品表Product_hit產品點擊表IdProduct_idNameHit_timeCategoryid產品類別Hit_ip點擊的Input_dateS,,p.input_datefromcategoryc,productspwhereSelectp.id,,count(duct_id)fromproductsp,product_hitwhere group orderbycount(duct_id)desclimitSelectp.id,,count(duct_id)numfromproductsp,product_hithwherep.id=duct_id groupby orderbynumdesclimit10showstatusex寫出統計1989-1-1后出生的數量的SQL語Selectcount(*)fromstuwherebirth>’1989-1-1’andsql用戶用戶編號用戶號,用戶通訊地址,用戶,編號,名稱,種類,用戶訂閱的編號 B、有一個新用戶(號=139000000000,通訊地址=A,=P,用戶=N),要訂閱某本(編號=100001).請寫出需要執行的SQL語句:>select*from11213243>select*from123 Selectp.id,,count(c.id)fromcityc,vince_id=p.idgroupbyp.id30、關系S(s#,sname, ),C(c#,cname),SC(s#,c#).其中S#為學生號,sname為學生, 為,c#為課程號,cname為課程名。SelectS.s#,S.sname,S. fromS,SCWhereS.s#=SC.s#andS. =”女”andSC.c#in(selectc#fromCwherecname=”計算機”)selectS.snamefromS,C,SCwhereS.s#=SC.s#andC.c#=SC.c# ame=’計算機’andS. select*fromSwhereS.s#notin(Select S.s#fromS,SCWhereS.s#=SC.s#andSC.c#in(Selectc#fromCwherecname=”數學”))用戶分配所有權限從ip來mysdb數據庫(root用戶為空mysql>createdatabaseifnotexistsmysql>grantallprivilegesonmydb.*toroot@identifiedbymysql>flushprivileges;//刷新系統權限表表2(MyISAM(InnoDB35、請對于據select*fromtableExamplewhere((aandb)andcor(((aandb)and(candd)))優化的語句。select*fromtableExamplewhereaandbandselect*fromloginwherenamelike“%admin%”limit10;40、在數據庫test中的一個表student,字段是name,class,score。分別代表、selectclass,count(if(score>=60,score,null)),count(if(score<60,score,null))fromstudentgroupbyclassselectsum(score<60)fromstudentgroupbyIntaltertableuseradd tinyintnotnulldefault1;B、查詢出介于20歲到30歲之間的用戶select*fromuserwhereagebetween20andC、如果是一個Web頻繁的查詢,上題的查詢如何優化?(為age字段添加索引)altertableuseraddindexindex_age(age);friend請使用php連接mysql,選擇出friend表里age20的所有記錄打印結果,并統計出userid(int),namescoreuidint),subject(varchar),score(int)selectlast_insert_id();select*fromscorewhereuid=2orderbyscoredesclimit5(3)使用聯合查詢獲取name為“”的用戶的總分數selectsum(s.score)fromuseru,scoreswhereu.id==”清空score表deletefrom刪除userdroptableMysqlinsertID1815? 74MYSQL(命令行、工具)75memcache(分布式,84一個article表含有titlecladaine以及其他字段請寫sql語句, 的8篇文章。select*fromarticleorderbydainedesclimit85、一個article表字段為id/title/type_id/author/content/daine/active,article_type表字段為id/title。要求顯示article表的5條文章作者和文章分類名 a.type_id=t.idorderbydainedesclimit586、從表a中刪除id大于5同 為1的記錄deletefromawhereid>5 87b表和cbcsql語句并insertintocselect*fromselect*frommembersorderbypostsdesclimit兩張表pany和Job,分別表示公司和職位表中含有字段NameIDJob表中含有字段:Id,City,CreateDateID,公司IdSQL日期倒序。orderby.idasc,Job.createDatedescmysql>grantallprivilegesonTEST_DB.*totestuser@00identifiedby'106、寫出選擇出銷售額最高的十個產品的SQL語句,利用下表:(product_id,product_name,price,sell_num);其中product_idi(主鍵,price,sell_numselect*fromproductsorderbyprice*sell_numdesclimit10;108、MYSQL TABLEidintunsignedAUTO_INCREMENT,user_idintunsignedcomment‘id’,tysmallintunsignedcomment‘本次產品數量’,pay_timetimestampcomment‘時間’,PRIMARY)用戶每成功付款一筆訂單(從進入到離開),會增加一條記錄,記錄用戶的ID(user_id),以及的產品數量。比如:1、208,2//208這個用戶2個產select*frompaymentwhereuser_id=100orderbypay_timedesclimitselect*frompaymentwhereuser_id=100orderby

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論