版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、下面是sql server 和 access 操作數(shù)據(jù)庫結(jié)構(gòu)的常用sql,希望對你有所幫助。新建表:create table 表名(自動編號字段 int identity (1,1) primary key ,字段1 nvarchar(50) default 默認值 null ,字段2 ntext null ,字段3 datetime,字段4 money null ,字段5 int default 0,字段6 decimal (12,4) default 0,字段7 image null ,)刪除表:drop table 表名插入數(shù)據(jù):insert into 表名 (字段1,字段2) valu
2、es (100,51windows.net)刪除數(shù)據(jù):delete from 表名 where 字段名100更新數(shù)據(jù):update 表名 set 字段1 = 200,字段2 = 51windows.net where 字段三 = haiwa新增字段:alter table 表名 add 字段名 nvarchar (50) null刪除字段:alter table 表名 drop column 字段名修改字段:alter table 表名 alter column 字段名 nvarchar (50) null重命名表:(access 重命名表,請參考文章:在access數(shù)據(jù)庫中重命名表)sp_r
3、ename 表名, 新表名, object新建約束:alter table 表名 add constraint 約束名 check (約束字段 80);(3)法二select sno, avg(grade) averagefrom scgroup by snohaving(avg(grade)80);(4)delete from sc where sc.sno in( select sno from s where sname=s5);(5)select snamefrom swhere sdept=英語and sex=男;(6)select sc.sno,avg(grade) as aver
4、agefrom s,scwhere s.sno=sc.snogroup by sc.sno;(7)select s.sname as 姓名 ,grade as 成績 ,c.cname as 選修課程from sc,s,cwhere s.sno=sc.sno and sc.cno=c.cno and sc.cno in( select cno from c where cname=db);(8)select top 1 sno as 學號,grade as 分數(shù),cname as 課程名from sc,cwhere sc.cno=c.cno and cname=osorder by grade
5、desc;(9)select snamefrom swhere not exists( select * from sc where sno=s.sno and cno=1);(10)select snamefrom swhere not exists( select * from c where not exists( select * from sc where sno=s.sno and cno=c.cno);(11)select distinct snofrom sc,scxwhere not exists( select * from sc scy where scy.sno=950
6、01 and not exists( select * from sc scz where scz.sno=scx.sno and scz.cno=scy.cno);(12)select top 3 cno as 課程號, snofrom scwhere cno=1order by grade desc;create database stu use stu create table s ( sno char(6), sname char(10), age int, sex char(2), constraint pk_s primary key (sno), constraint ck_age check(age=0 and age=0) ) create table sc ( sno char(6), cno char (8), constraint pk_sc primary key (sno,cno), constraint fk_s foreign key (sno) references s(sno), constraint fk_c foreign key (cno) re
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 幼兒園創(chuàng)意手工布藝教案案例
- 永州生物中考試卷解析
- 企業(yè)遵紀守法員工手冊及常見案例解析
- 跨境電子商務基礎(chǔ)教學課件6-5-其他物流方式
- 幼兒園慶典活動策劃與祝詞范本
- 株洲市中考語文歷年真題解析
- 保險經(jīng)紀公司運營流程優(yōu)化方案
- 班級品格教育主題班會方案
- 全國大學生臨床技能實操競賽題庫
- 公路養(yǎng)護管理技術(shù)規(guī)范及案例匯編
- 廣東省大灣區(qū)2023-2024學年高一上學期期末生物試題【含答案解析】
- 第四單元地理信息技術(shù)的應用課件 【高效課堂+精研精講】高中地理魯教版(2019)必修第一冊
- 魯科版高中化學必修一教案全冊
- 提高隧道初支平整度合格率
- 2023年版測量結(jié)果的計量溯源性要求
- 建筑能耗與碳排放研究報告
- GB 29415-2013耐火電纜槽盒
- 中國古代經(jīng)濟試題
- 軟件定義汽車:產(chǎn)業(yè)生態(tài)創(chuàng)新白皮書
- 磷石膏抹灰專項施工方案
- 水電水利工程施工質(zhì)量管理培訓講義
評論
0/150
提交評論