易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : sql

ASP.NET防止SQL注入函数

ASP.NET防止SQL注入函数:
using System;
using System.Text.RegularExpressions;
using System.Web;
namespace FSqlKeyWord
......{
    /**//**//**//// <summary>
    /// SqlKey 的摘要说明。
    /// </summary>
    public class SqlKey
    ......{
        private HttpRequest request;
        private const string StrKeyWord = @"select|insert|delete|from|count(|drop table|update|truncate|asc(|mid(|char(|xp_cmdshell|exec master|netlocalgroup administrators|:|net user|""|or|and";
        private const string StrRegex = @"[-|;|,|/|(|)|[|]|}|{|%|@|*|!|']";
        public SqlKey(System.Web.HttpRequest _request)
        ......{
            //
     &nbs ......

ASP.NET防止SQL注入函数

ASP.NET防止SQL注入函数:
using System;
using System.Text.RegularExpressions;
using System.Web;
namespace FSqlKeyWord
......{
    /**//**//**//// <summary>
    /// SqlKey 的摘要说明。
    /// </summary>
    public class SqlKey
    ......{
        private HttpRequest request;
        private const string StrKeyWord = @"select|insert|delete|from|count(|drop table|update|truncate|asc(|mid(|char(|xp_cmdshell|exec master|netlocalgroup administrators|:|net user|""|or|and";
        private const string StrRegex = @"[-|;|,|/|(|)|[|]|}|{|%|@|*|!|']";
        public SqlKey(System.Web.HttpRequest _request)
        ......{
            //
     &nbs ......

删除sql 2005 日志

1、截断日志:  
  backup   log   数据库   with   no_log  
   
  或:  
  清空日志  
  DUMP     TRANSACTION     库名     WITH     NO_LOG    
   
  2、  
  企业管理器--右键你要压缩的数据库--所有任务--收缩数据库--收缩文件--选择日志文件--在收缩方式里选择收缩至XXM,这里会给出一个允许收缩到的最小M数,直接输入这个数,确定就可以了 ......

JSP防SQL注入攻击

第一种采用预编译语句集,它内置了处理SQL注入的能力,只要使用它的setString方法传值即可:
String sql= "select * from users where username=? and password=?;
PreparedStatement preState = conn.prepareStatement(sql);
preState.setString(1, userName);
preState.setString(2, password);
ResultSet rs = preState.executeQuery();
...
第二种是采用正则表达式将包含有 单引号('),分号(;) 和 注释符号(--)的语句给替换掉来防止SQL注入
例1
public static String TransactSQLInjection(String str)
{
return str.replaceAll(".*([';]+|(--)+).*", " ");
}
userName=TransactSQLInjection(userName);
password=TransactSQLInjection(password);
String sql="select * from users where username='"+userName+"' and password='"+password+"' "
Statement sta = conn.createStatement();
ResultSet rs = sta.executeQuery(sql);
...
或者例2
要引入的包:
import java.util.regex.*;
正则表达式:
private String CHECKSQL = “^(.+)\\sand\\s(.+)|(.+)\\sor(.+)\\s$”;
判断是否匹配:
Pattern.matches(CHECKSQL ......

JSP防SQL注入攻击

第一种采用预编译语句集,它内置了处理SQL注入的能力,只要使用它的setString方法传值即可:
String sql= "select * from users where username=? and password=?;
PreparedStatement preState = conn.prepareStatement(sql);
preState.setString(1, userName);
preState.setString(2, password);
ResultSet rs = preState.executeQuery();
...
第二种是采用正则表达式将包含有 单引号('),分号(;) 和 注释符号(--)的语句给替换掉来防止SQL注入
例1
public static String TransactSQLInjection(String str)
{
return str.replaceAll(".*([';]+|(--)+).*", " ");
}
userName=TransactSQLInjection(userName);
password=TransactSQLInjection(password);
String sql="select * from users where username='"+userName+"' and password='"+password+"' "
Statement sta = conn.createStatement();
ResultSet rs = sta.executeQuery(sql);
...
或者例2
要引入的包:
import java.util.regex.*;
正则表达式:
private String CHECKSQL = “^(.+)\\sand\\s(.+)|(.+)\\sor(.+)\\s$”;
判断是否匹配:
Pattern.matches(CHECKSQL ......

oracle sql优化之多表连接优化


Use equality first.
使用等连接
Use range operators only where equality does not apply.
只有在等连接不可用的情况下事由区间连接
Avoid use of negatives in the form of !=
or NOT.
避免使用 != 或者 not
Avoid LIKE pattern matching.
避免使用 LIKE匹配
Try to retrieve specific rows and in small numbers.
尝试查找特殊的列和在小的数目中
Filter from large tables first to reduce rows joined.
Retrieve tables in order from the most highly filtered table downwards;
preferably the largest table has the most filtering applied.
过滤大表减少连接的行数,从过滤多的表向下查找,尽可能的过滤大表
Tip 
The most highly filtered table is the table having the
smallest percentage of its rows retrieved, preferably the largest
table.
Use indexes wherever possible except for very small
tables.
除非很小的表,无论什么情况多有索引
Let the Optimizer do its job.
让优化器做优化
......

oracle sql优化之多表连接优化


Use equality first.
使用等连接
Use range operators only where equality does not apply.
只有在等连接不可用的情况下事由区间连接
Avoid use of negatives in the form of !=
or NOT.
避免使用 != 或者 not
Avoid LIKE pattern matching.
避免使用 LIKE匹配
Try to retrieve specific rows and in small numbers.
尝试查找特殊的列和在小的数目中
Filter from large tables first to reduce rows joined.
Retrieve tables in order from the most highly filtered table downwards;
preferably the largest table has the most filtering applied.
过滤大表减少连接的行数,从过滤多的表向下查找,尽可能的过滤大表
Tip 
The most highly filtered table is the table having the
smallest percentage of its rows retrieved, preferably the largest
table.
Use indexes wherever possible except for very small
tables.
除非很小的表,无论什么情况多有索引
Let the Optimizer do its job.
让优化器做优化
......

SQL SERVER 究竟什么时候写日志?

昨天看到网上有一个关于SQL SERVER 课件,便随手下载了下来看看主要讲了些什么内容,于是看到了下面两个PPT页面
   

    由于第一张PPT上的内容不太准确(日志文件中没有“日志页”的概念,只有VLF的概念,可能是我们对“数据页”的概念太深刻了,因此弄了以“日志页”的概念出来,而PPT中说先更新高速缓冲区中的数据页,然后将事务日志写入到“日志页”,很容易让人理解成先更改高速缓冲区,然后将日志写入到磁盘上的“日志页”),再加上我看PPT时比较"囫囵"(只看到前一张PPT,没有往后翻两下看后面一张PPT).因此我觉得PPT的作者在日志的写入顺序上有问题.索性查了一下资料,然后比较深入的思考了日志的写入顺序问题,同时也纠正了一些自己以往的不正确理解.
    该文主要包含以下内容:
     1.SQL SERRVER 日志管理器的大致工作内容与原理.
     2.实例探究SQL SERVER 事务日志的产生与写入磁盘磁盘. 
     3.一些其它的相关思考.
    第一部分:SQL SERVER 日志管理器的大致工 ......

Oracle开发之SQL语句案例—分析函数的使用

创建雇员表:
create table emp(deptno number(10),ename varchar2(100),sal number(10,2));
插入数据
begin
insert into emp values('10','KING',5000);
insert into emp values('10','CLARK',2450);
insert into emp values('10','MILLER',1300);
insert into emp values('20','SCOTT',3000);
insert into emp values('20','FORD',3000);
insert into emp values('20','JONES',2975);
insert into emp values('20','ADAMS',1100);
insert into emp values('20','SMITH',800);
insert into emp values('30','BLAKE',2850);
insert into emp values('30','ALLEN',1600);
insert into emp values('30','TURNER',1500);
insert into emp values('30','WARD',1250);
insert into emp values('30','MARTIN',1250);
insert into emp values('30','JAMES',950);
commit;
end;
1、使用row_number()、rank()、dense_rank()查出各部门薪水最高的三个员工姓名、薪水,多于三个的只取三个。
select *
  from (select e.deptno,
               e.ename,
    & ......

Oracle开发之SQL语句案例—分析函数的使用

创建雇员表:
create table emp(deptno number(10),ename varchar2(100),sal number(10,2));
插入数据
begin
insert into emp values('10','KING',5000);
insert into emp values('10','CLARK',2450);
insert into emp values('10','MILLER',1300);
insert into emp values('20','SCOTT',3000);
insert into emp values('20','FORD',3000);
insert into emp values('20','JONES',2975);
insert into emp values('20','ADAMS',1100);
insert into emp values('20','SMITH',800);
insert into emp values('30','BLAKE',2850);
insert into emp values('30','ALLEN',1600);
insert into emp values('30','TURNER',1500);
insert into emp values('30','WARD',1250);
insert into emp values('30','MARTIN',1250);
insert into emp values('30','JAMES',950);
commit;
end;
1、使用row_number()、rank()、dense_rank()查出各部门薪水最高的三个员工姓名、薪水,多于三个的只取三个。
select *
  from (select e.deptno,
               e.ename,
    & ......
总记录数:4346; 总页数:725; 每页6 条; 首页 上一页 [657] [658] [659] [660] 661 [662] [663] [664] [665] [666]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号