




免费预览已结束,剩余3页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1create database database-name2drop database dbname3sql server- deviceuse masterexec sp_addumpdevice disk, testback, c:mssql7backupmynwind_1.dat- backup database pubs to testback4create table tabname(col1 type1 not null primary key,col2 type2 not null,.) acreate table tab_new like tab_old ()bcreate table tab_new as select col1,col2? from tab_old definition only5drop table tabname6alter table tabname add column col typedb2varchar7 alter table tabname add primary key(col) alter table tabname drop primary key(col)8create unique index idxname on tabname(col?.)drop index idxname9create view viewname as select statementdrop view viewname10sqlselect * from table1 where insert into table1(field1,field2) values(value1,value2)delete from table1 where update table1 set field1=value1 where select * from table1 where field1 like %value1% -like! select * from table1 order by field1,field2 descselect count as totalcount from table1select sum(field1) as sumvalue from table1select avg(field1) as avgvalue from table1select max(field1) as maxvalue from table1select min(field1) as minvalue from table111a union union table1 table2 all union union all table1 table2b except except table1 table2 all except (except all)c intersect intersect table1 table2 all intersect (intersect all)12aleft outer joinsql: select a.a, a.b, a.c, b.c, b.d, b.f from a left out join b on a.a = b.cbright outer join:()cfull outer join1(,a b) (access)select * into b from a where 1<>1select top 0 * into b from a2(,a b) (access)insert into b(a, b, c) select d,e,f from b;3() (access)insert into b(a, b, c) select d,e,f from b in where .from b in &server.mappath(.)&data.mdb & where.4(1a 2b)select a,b,c from a where a in (select d from b ) : select a,b,c from a where a in (1,2,3)5select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b6(1a 2b)select a.a, a.b, a.c, b.c, b.d, b.f from a left out join b on a.a = b.c7(1a )select * from (select a,b,c from a) t where t.a > 1;8between,between,not betweenselect * from table1 where time between time1 and time2select a,b,c, from table1 where a not between 1 and 29in select * from table1 where a not in (1,2,4,6)10delete from table1 where not exists ( select * from table2 where table1.field1=table2.field1 )11select * from a left inner join b on a.a=b.b right inner join c on a.a=c.c inner join d on a.a=d.d where .12sql: select * from where datediff(minute,f,getdate()>513sql select top 10 b.* from (select top 20 , from order by desc) a, b where b. = a. order by a.1410select top 10 * form table1 where 15ba(,.)select a,b,c from tablename ta where a=(select max(a) from tablename tb where tb.b=ta.b)16 tablea tablebtablec (select a from tablea ) except (select a from tableb) except (select a from tablec)1710select top 10 * from tablename order by newid()18select newid()19delete from tablename where id not in (select max(id) from tablename group by col1,col2,.)20select name from sysobjects where type=u / u21select name from syscolumns where id=object_id(tablename)22typevenderpcstypecaseselect caseselect type,sum(case vender when a then pcs else 0 end),sum(case vender when c then pcs else 0 end),sum(case vender when b then pcs else 0 end) from tablename group by type type vender pcs a 1 a 1 b 2 a 2 b 3 c 323table1truncate table table1241015select top 5 * from (select top 15 * from table order by id asc) table_ order by id desc11=11=2sqlwhere 1=1 where 1=2if strwhere !=beginset strsql = select count(*) as total from + tblname + where + strwhere endelsebeginset strsql = select count(*) as total from + tblname + endset strsql = select count(*) as total from + tblname + where 1=1 + strwhere2-dbcc reindexdbcc indexdefrag-dbcc shrinkdbdbcc shrinkfile3dbcc shrinkdatabase(dbname)4exec sp_change_users_login update_one,newname,oldnamego5restore verifyonly from disk=e:dvbbs.bak6alter database dvbbs set single_usergodbcc checkdb(dvbbs,repair_allow_data_loss) with tablockgoalter database dvbbs set multi_usergo7set nocount ondeclare logicalfilename sysname,maxminutes int,newsize intusetablename - selectlogicalfilename = tablename_log,- maxminutes = 10, - limit on time allowed to wrap log. newsize = 1 - (m) - setup / initializedeclare originalsize intselect originalsize = sizefrom sysfileswhere name = logicalfilenameselect original size of + db_name() + log is +convert(varchar(30),originalsize) + 8k pages or + convert(varchar(30),(originalsize*8/1024) + mbfrom sysfileswhere name = logicalfilenamesql()sql 2009-06-08 12:12mysql transact-sqlfromwheretesttablenicknameemail:select nickname,emailfrom testtablewhere name=() (select_list)()1testtable:select * from testtable2:select nickname,email from testtable3= :select =nickname,=email from testtable4selectalldistinctalldistinctselect5top n percenttop nntop n percentn:select top 2 * from testtable:select top 20 percent * from testtable() fromfromselectfrom256fromusertablecitytablecityidcityid:select username,citytable.cityidfrom usertable,citytablewhere usertable.cityid=citytable.cityidfrom: as :select username,b.cityidfrom usertable a,citytable bwhere a.cityid=b.cityidselect:select a.au_fname+a.au_lnamefrom authors a,titleauthor ta(select title_id,titlefrom titleswhere ytd_sales>10000) as twhere a.au_id=ta.au_idand ta.title_id=t.title_idselectt() wherewhere20 :select * from usertable where age>20 where ()>>=!>!=10 and age:select * from usertable order by age desc,userid asc unionselectunion:select_statementunion all selectstatementunion all selectstatementnselectstatementselect allunion union1 union (2 union 3)sqlmssqlaccesssqlddl(createalterdropdeclare)dml(selectdeleteupdateinsert),1create database database-name2drop database dbname3sql server- deviceuse masterexec sp_addumpdevice disk, testback, c:mssql7backupmynwind_1.dat- backup database pubs to testback4create table tabname(col1 type1 not null primary key,col2 type2 not null,.)acreate table tab_new like tab_old ()bcreate table tab_new as select col1,col2? from tab_old definition only5drop table tabname6alter table tabname add column col typedb2varchar7alter table tabname add primary key(col)alter table tabname drop primary key(col)8create unique index idxname on tabname(col?.)drop index idxname9create view viewname as select statementdrop view viewname10sqlselect * from table1 where insert into table1(field1,fie
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年五类地理考试原题及答案
- 2025年儿科半期考试题及答案
- 慕课课件发布时间设置
- 中基考试简答题及答案
- 脂肪瘤考试试题及答案
- 情志病科普知识培训课件
- 海南旅游自考试卷及答案
- 湖南省岳阳市汨罗市第二中学2025-2026学年高二上学期开学考试化学试卷
- 育婴员考试面试题及答案
- 工厂管理考试题目及答案
- 《中国碳达峰碳中和政策与行动(2023)》
- 儿科护理质量管理持续改进
- 外科护理学绪论
- 因公出国人员审查表
- 房建装修拆除专项施工方案
- 盐雾试验报告
- 《中华民族大团结》(初中)第1课-爱我中华教学课件
- 第4章“免疫调节”单元教学设计 高二上学期生物人教版选择性必修1
- 高纯镁砂的生产技术及生产现状
- 急性会厌炎护理查房
- 混凝土模板工程验收表(含续表)GDAQ2090202
评论
0/150
提交评论