首先,要介l基语句Q?br />1、说明:创徏数据?br />Create DATABASE database-name 2、说明:删除数据?br />drop database dbname 3、说明:备䆾sql server --- 创徏 备䆾数据的 device USE master EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat' --- 开始 备?br />BACKUP DATABASE pubs TO testBack 4、说明:创徏新表 create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..) Ҏ已有的表创徏新表Q?br />AQcreate table tab_new like tab_old (使用旧表创徏新表) BQcreate table tab_new as select col1,col2… from tab_old definition only 5、说明:删除新表drop table tabname 6、说明:增加一个列 Alter table tabname add column col type 注:列增加后不能删除。DB2中列加上后数据类型也不能改变Q唯一能改变的是增加varcharcd的长度?br />7、说明:d主键Q Alter table tabname add primary key(col) 说明Q删除主键: Alter table tabname drop primary key(col) 8、说明:创徏索引Qcreate [unique] index idxname on tabname(col?) 删除索引Qdrop index idxname 注:索引是不可更改的Q想更改必须删除重新建?br />9、说明:创徏视图Qcreate view viewname as select statement 删除视图Qdrop view viewname 10、说明:几个单的基本的sql语句 选择Qselect * from table1 where 范围 插入Qinsert into table1(field1,field2) values(value1,value2) 删除Qdelete from table1 where 范围 更新Qupdate table1 set field1=value1 where 范围 查找Qselect * from table1 where field1 like ?value1%’?--like的语法很_֦Q查资料! 排序Qselect * from table1 order by field1,field2 [desc] LQselect count * as totalcount from table1 求和Qselect sum(field1) as sumvalue from table1 q_Qselect avg(field1) as avgvalue from table1 最大:select max(field1) as maxvalue from table1 最:select min(field1) as minvalue from table1 11、说明:几个高查询q算?br />AQ UNION q算W?br />UNION q算W通过l合其他两个l果表(例如 TABLE1 和 TABLE2Qƈ消去表中M重复行而派生出一个结果表。当 ALL 随 UNION 一起用时Q即 UNION ALLQ,不消除重复行。两U情况下Q派生表的每一行不是来自 TABLE1 是来自 TABLE2。?br />BQ EXCEPT q算W?br />EXCEPT q算W通过包括所有在 TABLE1 中但不在 TABLE2 中的行ƈ消除所有重复行而派生出一个结果表。当 ALL 随 EXCEPT 一起用时 (EXCEPT ALL)Q不消除重复行。?br />CQ INTERSECT q算W?br />INTERSECT q算W通过只包括 TABLE1 和 TABLE2 中都有的行ƈ消除所有重复行而派生出一个结果表。当 ALL 随 INTERSECT 一起用时 (INTERSECT ALL)Q不消除重复行。?br />注:使用q算词的几个查询l果行必L一致的。?br />12、说明:使用外连接?br />A、left outer joinQ?br />左外q接Q左q接Q:l果集几包括q接表的匚w行,也包括左q接表的所有行。?br />SQL: select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c BQright outer join: 叛_q接(双?Q结果集既包括连接表的匹配连接行Q也包括双接表的所有行。?br />CQfull outer joinQ?br />全外q接Q不仅包括符可接表的匹配行Q还包括两个q接表中的所有记录?br /> 其次Q大家来看一些不错的sql语句 1、说明:复制?只复制结?源表名:a 新表名:b) (Access可用) 法一Qselect * into b from a where 1<>1 法二Qselect top 0 * into b from a
2、说明:拯?拯数据,源表名:a 目标表名Qb) (Access可用) insert into b(a, b, c) select d,e,f from b;
3、说明:跨数据库之间表的拯(具体数据使用l对路径) (Access可用) insert into b(a, b, c) select d,e,f from b in ‘具体数据库’ where 条g 例子Q?.from b in '"&Server.MapPath(".")&"\data.mdb" &"' where..
4、说明:子查?表名1Qa 表名2Qb) 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)
5、说明:昄文章、提交h和最后回复时?br />select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b
6、说明:外连接查?表名1Qa 表名2Qb) select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c
7、说明:在线视图查询(表名1Qa ) select * from (Select a,b,c FROM a) T where t.a > 1;
8、说明:between的用?between限制查询数据范围时包括了边界?not between不包?br />select * from table1 where time between time1 and time2 select a,b,c, from table1 where a not between 数? and 数?
9、说明:in 的用方?br />select * from table1 where a [not] in (‘??’??’??’??
10、说明:两张兌表,删除主表中已l在副表中没有的信息 delete from table1 where not exists ( select * from table2 where table1.field1=table2.field1 )
11、说明:四表联查问题Q?br />select * 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 .....
12、说明:日程安排提前五分钟提醒?br />SQL: select * from 日程安排 where datediff('minute',f开始时?getdate())>5
13、说明:一条sql 语句搞定数据库分?br />select top 10 b.* from (select top 20 主键字段,排序字段 from 表名 order by 排序字段 desc) a,表名 b where b.主键字段 = a.主键字段 order by a.排序字段
14、说明:?0条记?br />select top 10 * form table1 where 范围
15、说明:选择在每一lb值相同的数据中对应的a最大的记录的所有信?cMq样的用法可以用于论坛每月排行榜,每月热销产品分析,按科目成l排?{等.) select a,b,c from tablename ta where a=(select max(a) from tablename tb where tb.b=ta.b)
16、说明:包括所有在 TableA 中但不在 TableB和TableC 中的行ƈ消除所有重复行而派生出一个结果表 (select a from tableA ) except (select a from tableB) except (select a from tableC)
17、说明:随机取出10条数?br />select top 10 * from tablename order by newid()
18、说明:随机选择记录 select newid()
19、说明:删除重复记录 Delete from tablename where id not in (select max(id) from tablename group by col1,col2,...)
20、说明:列出数据库里所有的表名 select name from sysobjects where type='U'
21、说明:列出表里的所有的 select name from syscolumns where id=object_id('TableName')
22、说明:列示type、vender、pcs字段Q以type字段排列Qcase可以方便地实现多重选择Q类似select 中的case?br />select 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 昄l果Q?br />type vender pcs 电脑 A 1 电脑 A 1 光盘 B 2 光盘 A 2 手机 B 3 手机 C 3
23、说明:初始化表table1 TRUNCATE TABLE table1
24、说明:选择?0?5的记?br />select top 5 * from (select top 15 * from table order by id asc) table_别名 order by id desc
不必写出RNumber 和IDQ你只需要检查匹配情况即可。只要你对以上代码的工作满意Q你自可按需操作“随机”记录。Recordset没有包含其他内容Q因此你很快p扑ֈ你需要的记录q样大大降低了处理旉。?br />再谈随机敊W?br /> 现在你下定决心要榨干Random 函数的最后一滴aQ那么你可能会一ơ取出多条随录或者想采用一定随围内的记录。把上面的标准Random CZ扩展一下就可以用SQL应对上面两种情况了。?br /> Z取出几条随机选择的记录ƈ存放在同一recordset内,你可以存储三个随机数Q然后查询数据库获得匚wq些数字的记录: SQL = "Select * FROM Customers Where ID = " & RNumber & " or ID = " & RNumber2 & " or ID = " & RNumber3
假如你想选出10条记录(也许是每ơ页面装载时?0条链接的列表Q,你可以用BETWEEN 或者数学等式选出W一条记录和适当数量的递增记录。这一操作可以通过好几U方式来完成Q但是 Select 语句只显CZU可能(q里的ID 是自动生成的LQ: SQL = "Select * FROM Customers Where ID BETWEEN " & RNumber & " AND " & RNumber & "+ 9"
注意Q以上代码的执行目的不是查数据库内是否有9条ƈ发记录?br />
随机d若干条记录,试q?br />Access语法QSelect top 10 * From 表名 orDER BY Rnd(id) Sql server:select top n * from 表名 order by newid() mysqlelect * From 表名 order By rand() Limit n Access左连接语?最q开发要用左q接,Access帮助什么都没有,|上没有Access的SQL说明,只有自己试, 现在C以备后查) 语法elect table1.fd1,table1,fd2,table2.fd2 From table1 left join table2 on table1.fd1,table2.fd1 where ... 使用SQL语句 ?..代替q长的字W串昄 语法Q?br />SQL数据库:select case when len(field)>10 then left(field,10)+'...' else field end as news_name,news_id from tablename Access数据库:Select iif(len(field)>2,left(field,2)+'...',field) FROM tablename;
"Error in writing to directory c:\temp\OraInstall, please ensure this directory is writable and has atleast 25 MB of disk space. Installation cannot countinue."
]]>MDAC unter Windows XP Service Pack 2 neu installierenhttp://m.tkk7.com/badboyryan/archive/2006/08/31/66893.html坏男?/dc:creator>坏男?/author>Thu, 31 Aug 2006 08:32:00 GMThttp://m.tkk7.com/badboyryan/archive/2006/08/31/66893.htmlhttp://m.tkk7.com/badboyryan/comments/66893.htmlhttp://m.tkk7.com/badboyryan/archive/2006/08/31/66893.html#Feedback0http://m.tkk7.com/badboyryan/comments/commentRss/66893.htmlhttp://m.tkk7.com/badboyryan/services/trackbacks/66893.htmlMDAC unter Windows XP Service Pack 2 neu installieren
Grundlegende Information
Windows XP mit Service Pack 2 enthält die MDAC-Version 2.81, welche derzeit für Windows XP nicht als eigenständiger Download erhältlich ist. Sie können auch keine ältere Version installieren, weil das Setup nicht ausgeführt wird. Mit den nachfolgend erklärten Schritten werden die MDAC-Dateien von SP2 neu installiert und und in vielen Fällen repariert.
So installieren Sie MDAC 2.81 unter Windows XP SP2 neu:
Öffnen Sie mit dem Windows-Explorer den Ordner C:\Windows\inf und suchen Sie nach der Datei mdac.inf. Hinweise: - Je nach System kann der Windows-Ordner auch anders lauten, wie z.B. C:\WinXP etc. - Wenn der Ordner oder die Datei nicht sichtbar ist, müssen Sie im Explorer unter Extras, Ordneroptionen die Anzeige versteckter Ordner und Dateien erst einschalten.
Kicken Sie mit der rechten Maustaste auf die Datei mdac.inf und wählen Sie den Befehl Installieren.
Sie werden schließlich nach der Datei adcjavas.inc gefragt. Geben Sie dann den Ordner C:\Windows\servicepackfiles\i386 aus. Wenn der Ordner nicht vorhanden ist, bitte Windows-CD einlegen.
Hinweis:Je nach System kann der Windows-Ordner auch anders lauten, wie z.B. C:\WinXP etc.
Sie werden schließlich nach der Datei handler.reg gefragt. Geben Sie dann den Ordner C:\Programme\Gemeinsame Dateien\System\msadc an. Hinweis: Der Ordner c:\Programme kann auf Ihrem System wo anders liegen.
Wenn die Datei MDACRdMe.htm nicht gefunden wird, öffnen Sie folgenden Ordner: C:\Programme\Gemeinsame Dateien\System\ado Ändern Sie die dort ggf. vorhandene Datei MDACReadme.htm in MDACRdMe.htm ab und verweisen Sie darauf.
Wenn die Datei oledbjvs.inc nicht gefunden wird, verweisen Sie auf folgenden Ordner: C:\Programme\Gemeinsame Dateien\System\Ole DB
Wenn die Datei mssoap1.dll nicht gefunden wird, verweisen Sie auf folgenden Ordner: C:\Programme\Gemeinsame Dateien\MSSoap\Binaries
Wenn die Datei mssoapr.dll nicht gefunden wird, verweisen Sie auf folgenden Ordner: C:\Programme\Gemeinsame Dateien\MSSoap\Binaries\Resources\1031