SQL加密数据
王燕杰
在网络上发送数据都会发生一些严重的安全问题,网络最大的担忧在于有人可以捕获数据,sqlserver支持采用证书来加密
1.创建证书
create master key encryption by
password = 'administrator123'
--用密码admini--
create certificate c1
encryption by password = 'administrator123'
with subject = 'c1 certificate',
start_date='03/08/2009',
expiry_date = '02/08/2020';
go
2.创建测试表,name字段为要加密的列,数据类型为varbinary
注意:加密的类型必须是varbinary,因为加密的数据是类型varbinary
create table testB(id int identity(1,1),name varbinary(5000))
3.使用加密函数向测试表中写入一条测试数据
insert into testB(name)
select encryptbycert(cert_id('c1'),'test')
4.利用下面的语句来提取加密数据
select * from testB
5.利用以下语句来解密数据
select id ,cast(decryptbycert(cert_id('c1'),name ,
N'administrator123')as varchar(20)) from testB
完成了
相关文档:
本文来自:http://niunan.javaeye.com/blog/264197
比较万能的分页:
select top 每页显示的记录数 * from topic where id not in
(select top (当前的页数-1)×每页显示的记录数 id from topic order by id& ......
select * from ((select bill.id billId,bach.riskRate risk,bach.assureRate assure from AcptBillInfo bill,AcptBach bach where bill.acptBatchId=bach.id and bill.rgctId=? )abach left outer join AcptSignMoney sig on abach.billId = sig.billId) ......
SQL字符串函数http://www.cnblogs.com/virusswb/archive/2008/09/10/1288576.html
select语句中只能使用sql函数对字段进行操作(链接sql server),
select 字段1 from 表1 where 字段1.IndexOf("云")=1;
这条语句不对的原因是indexof()函数不是sql函数,改成sql对应的函数就可以了。
left()是sql函数。
select 字 ......
Student(S#,Sname,Sage,Ssex) 学生表
Course(C#,Cname,T#) 课程表
SC(S#,C#,score) 成绩表
Teacher(T#,Tname) 教师表
问题:
1、查询“001”课程比“002”课程成绩高的所有学生的学号;
select a.S# from (select s#,score from SC where C#='001') a,(select s#,score
fr ......