資源描述:
《實(shí)驗(yàn)三簡(jiǎn)單查詢和連接查詢》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫(kù)。
1、實(shí)驗(yàn)三簡(jiǎn)單查詢和連接查詢實(shí)驗(yàn)?zāi)康模赫莆蘸?jiǎn)單表的數(shù)據(jù)查詢、數(shù)據(jù)排序和數(shù)據(jù)聯(lián)結(jié)查詢的操作方法。實(shí)驗(yàn)內(nèi)容:簡(jiǎn)單查詢操作、數(shù)據(jù)排序和數(shù)據(jù)聯(lián)結(jié)查詢。實(shí)驗(yàn)步驟:一.創(chuàng)建數(shù)據(jù)庫(kù):CREATEDATABASEXSGLON(NAME=*XSGL_DATA1,FILENAME^'E:sqlserver2005XSGL.MDF'z--改為你的目錄:egD:ABCXSGL.MDFSIZE=10MBfMAXSIZE=50MBzFILEGROWTH=5%)LOGON(NAME=1XSGL_Log',FILENAME='e:sqlserver2005XSGL_Log.l
2、df*ASIZE=2MBzMAXSIZE=5MB,FILEGROWTH=1MB)二.表的建立:useXSGLCreatetablestudent(snovarchar(10)NOTNULL,snamevarchar(10)NOTNULL,ssexvarchar(2)NOTNULL?sageintNULL,sdeptvarchar(10)NOTNULL)goCreatetablecourse(enovarchar(3)NOTNULL,cnamevarchar(30)NOTNULL,creditintNULL,penovarchar(3)NULL)goCr
3、eatetablesc(snovarchar(10)NOTNULL,enovarchar(3)NOTNULL,gradeINTNULL)goSelect*fromstudentSelect*fromcourseinsertintocourse(eno,cname,credit,peno)values(111,'數(shù)據(jù)庫(kù)―4,?51)insertintocourse(eno,cname,uredit,pcno)values(121f'數(shù)學(xué)6,null)insertintocourse(eno,cname,credit,peno)values(13'信,息
4、系統(tǒng)―3,⑴)insertintocourse(eno,cname,credit,peno)values(141z'操作系統(tǒng)―4,?61)insertintocourse(eno,cname,credit,peno)values(151,'數(shù)據(jù)結(jié)構(gòu),,4,'7*)insertintocourse(eno,cname,credit,peno)values(161,'數(shù)據(jù)處理J3,null)insertintocourse(eno,cnamezcredit,pcno)values(171f'PASCAL語(yǔ)言—4fG)Select*fromcourseSel
5、ect*fromscinsertintosc(sno,cnofgrade)values(*95001','I1,92)insertintosc(sno,eno,grade)values('95001',*2*,85)insertintosc(sno,cnofgrade)values('95001',3,88)insertintosc(sno,cnofgrade)values('95002*z*2?,90)insertintosc(sno,eno,grade)values('95002',3,80)insertintosc(sno,cnofgrade)v
6、alues('95003',2,85)insertintosc(sno,eno,grade)values('95004',*1*,58)insertSelectintosc(sno,eno,grade)*fromscvalues('950041,*2*,85)三.表數(shù)據(jù)的添加:Selectinsert男Jinsert*fromstudentintostudent(sno,sname,ssex^sage,sdept)values(195001','李勇1,120,^S*)intostudent(snozsname『ssexzsage,sdept)valu
7、es(!95002,z'劉晨J'女、,19,'IS')insertintostudent(sno,snamezJ'女、,18,*MA*)insertintostudent(sno,snamef'男J19,'IS')insertintostudent(sno,sname,*,'女、,18,*CS*)ssex,sage,sdept)ssex,sage,sdept)ssexzsage,sdept)values(f950031,'王敏values(1950041,values('950051,'張立嘆lj云四.簡(jiǎn)單查詢(選做4題)1、檢索學(xué)生張三的基本信息S
8、elect*fromstudentwheresname=,張三'2、檢索計(jì)科系和信息工程系學(xué)生