asp网页里,sql常用操作语句!
添加、删除、修改使用
db.Execute(Sql)命令执行操作
╔----------------╗
☆ 数据记录筛选 ☆
╚----------------╝
注意:单双引号的用法可能有误(没有测式)
Sql = "Select
Distinct
字段名 from 数据表"
Distinct函数,查询数据库存表内不重复的记录
Sql = "Select Count(*) from 数据表 where
字段名1>#18:0:0# and 字段名1< #19:00# "
count函数,查询数库表内有多少条记录,“字段名1”是指同一字段
例:
set rs=conn.execute("select count(id) as idnum from news")
response.write rs("idnum")
sql="select * from 数据表 where 字段名 between 值1 and
值2"
Sql="select * from 数据表 where 字段名 between
#2003-8-10# and #2003-8-12#"
在日期类数值为2003-8-10 19:55:08
的字段里查找2003-8-10至2003-8-12的所有记录,而不管是几点几分。
select * from tb_name where datetime between #2003-8-10# and
#2003-8-12#
字段里面的数据格式为:2003-8-10
19:55:08,通过sql查出2003-8-10至2003-8-12的所有纪录,而不管是几点几分。
Sql="select * from 数据表 where 字段名=字段值 order by
字段名 [desc]"
Sql="select * from 数据表 where 字段名 like ’’%字段值%’’
order by 字段名 [desc]"
模糊查询
注意:mysql与ORACLE数据库存在不同
Sql="select
top 10
*
from 数据表 where 字段名 order by 字段名 [desc]"
Sql="select *from数据表where字段名order by字段名[desc]
limit
10
"
查找数据库中前10记录
Sql="select top n * form 数据表 order by newid()"
随机取出数据库中的若干条记录的方法
top n,n就是要取出的记录数
Sql="select * from 数据表 where 字段名 in
(’’值1’’,’’值2’’,’’值3’’)"
╔----------------╗
☆ 添加数据记录 ☆
╚----------------╝
sql="insert into 数据表 (字段1,字段2,
相关文档:
详细地步骤:
1、打开MicroSoft Excel 2000
2、文件(F)→新建(N)→工作簿→
3、输入数据后,存盘为test.xls,
4、文件(F)→另存为(A)→
保存类型为:制表符分隔,起名为text.txt,保存到C:\ &nb ......
sql loader可以把一些以文本格式存放的数据顺利的导入到oracle数据库中,是一种在不同数据库之间进行数据迁移的非常方便而且通用的工具。 &n ......
一、问题的提出
在应用系统开发初期,由于开发数据库数据比较少,对于查询SQL语句,复杂视图的的编写等体会不出SQL语句各种写法的性能优劣,但是如果将应用系统提交实际应用后,随着数据库中数据的增加,系统的响应速度就成为目前系统需要解决的最主要的问题之一。系统优化中一个很重要的方 ......
使用了一段时间后,SQL Server 的 LDF文件体积巨大.
如何处理嘞, 对于 SQL Server 2005 及之前的版本,可以使用如下 SQL:
declare @name varchar(50)
set @name='dbname
'
backup
log @name
with truncate_only
dbcc shrinkdatabase (@name,20)
可是在 SQL Server 2008 开始,执行上面的语句会报错:
'truncate ......
<%
Set rs=Server.CreateObject("ADODB.RecordSet")
sql="select * from 0791idc_News where BigClassName='家装课堂' order by ID desc"
rs.Open sql,Conn,1,1
if rs.eof and rs.bof then
response.Write("暂时没有记录")
else
%>
......