Professional Documents
Culture Documents
1.1 SQL
1
2
3
1.2 SQL
1.3
1
1Windows
2
======================
2
Administrator/Sa
3
1Sysadmin
2SecurityAdmin
======================
4
dbo guest
guest
5
1db_Owner
2db_ddladmin
==========================
6
1
2
3
1.4
1
2
1.5 SQL
1 SA
2
3
4
5
6
7
--
create master key encryption by password='``11qqq'
--
-- cer1
--
--
start_date ='08/20/2010',
expiry_date='08/20/2011';
--
--
--
create table users
(
uid int identity(1,1) not null,
username nvarchar(20) not null,
password varbinary(5000)
-- varbinary
)
--
insert into users(username,password)
values('xiaohei',encryptbycert(cert_id('cert1'),'123'))
--: ,cast varbinary nvarchar
select uid,username,cast(decryptbycert(cert_id('cert1'),password,N'``11qqq') as varchar(20))
from users
8
1.6
select * from sys.symmetric_keys
--
--
T-SQL
2.1
1
-- 13701418965
Select ''+phonenumber+''+cast(charge as varchar(10))+'' AS
From accountbill
Where phonenumber='13701418965' AND
IsPaid = 0 AND calltype=0
2
--Dateadd yyyy / mm / dd
--Datediff hh / mi / ss
--Datepart year / month / day
-- 13701418965 2008 6 ,
as
From
"history-call"
Where
-- 13701418965
Select ' '+phonenumber+' '+cast(DATEPART(YEAR,accounttime) as Varchar(10))+'
'+cast(DATEPART(MONTH,accounttime) as Varchar(10))+' '+cast(charge as
varchar(10))+''
From accountbill
Where phonenumber='13701418965' AND
IsPaid = 0 AND calltype=0 Order By accounttime
2.2
--1
Select Count(*) as
From accountbill
Where ispaid=0
--2
Select Count(Distinct phonenumber) as
From accountbill
Where ispaid=0
--3
select phonenumber,sum(charge)
from dbo.accountbill
group by phonenumber
--4
select calltype,sum(charge)
from accountbill
group by calltype
--5 20000
select calltype,sum(charge) as
from accountbill
group by calltype
having sum(charge)>20000
--6 9999 10000
10002
select calltype,sum(charge) as
from accountbill
group by calltype
having count(*)>9999
--7 2008 2 7
Select
CAST
(DATEPART(YEAR,paytime)
as
varchar(10))+' '+
CAST
(DATEPART(MONTH,paytime) as varchar(10))+'' AS ,Sum(CHARGE)
From "history-accountbill" Where isPaid<>0 AND
paytime between '2008-02-01 00:00:00' and '2008-7-31 23:59:59'
Group By CAST (DATEPART(YEAR,paytime) as varchar(10))+' '+
(DATEPART(MONTH,paytime) as Varchar(10))+''
--8
select Titles.Title,Publishers.Pub_name from Publishers
Publishers.Pub_id=Titles.Pub_id
select Title.Title,Publishers.Pub_name from Publishers,Titles
inner
join
Titles
CAST
on
where Publishers.Pub_id=Titles.Pub_id
--9
Select Students.uname,Chengji.score
From Students Left Outer Join Chengji
on Students.uid=Chengji.uid
--10
SQL
3.1
1
3.2
1
2
3.3
1
2
3
3.4
1
1 I/O CPU
2
A
B
2
1
3
A
BLike %
C !=
not
D 20%=''
E
Fwith(index(Pid_Start_Endtime))
3.5
1
2
2 30%
3 30%
4.1
Database
Status
Command
Application
4.2 SQL
1
1
SQL SERVERMSSQL$BenetDB--Data files size(kb)
CPUProcessor--%processor time CPU
CPU
Process--%Processor time CPU
Memory--Pages/sec
1
1Audit Login
2Audit Logout
3BatchStarting T-SQL select
4BatchComplete
2 Porfier Alter Trace
-- SQL Server Profier
create table users
(
uid int,
username varchar(30),
password varchar(30)
)
declare @m int
set @m=1
while(@m<100000)
begin
insert into users values(1,'','123')
set @m=@m+1
end
4.4
*.trc
-
1
2 SSMS
use Tariffsmall
select * from "history-call" where phonenumber = '13801027953'
use Tariffsmall
select * from "history-call" where phonenumber = '13501187855'
use Tariffsmall
select * from "history-call" where phonenumber = '13401456527'
4.5
1
2
CPU
3
1
2 RAID
3 DBCC
4
--
Declare @db_id int, @tbl_id int
Use Tariffsmall
Set @db_id = DB_ID('Tariffsmall')
Set @tbl_id = Object_ID('accountbill')
DBCC pintable(@db_id, @tbl_id)
DBCC UNpintable (@db_id, @tbl_id)
accountbill
SQL
5.1
1
1
2
3
2
1
2
3
5.2
1 /
2+ /
3+ /
4++ /
5.3
1SQL
2
.bak
5.4 Master
1
1
2
3
4
2
master
1 SSMS master E
master.bak
2 SQL2005 ISO
3 services.msc SQL
4 C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
master.mdf master
5 cmd SQL
cd C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn
6 master master.mdf
6.1 SQL
1SQL
2SQL
1
A
B
C
2
.\administrator
6.2
1
2 IP
3
6.3
1
2
1 T-SQL
2
3WMI
6.4
7.1
1
1Oracle
2Access
3Excel
4
2
1 ====
2 ====
3 ====
4 ====
5T-SQL ==== select * into xinbiao from yuangong
6SSIS
7.2
7.3 SSIS
1SSIS
2
Call.txt call
proctariffpersonal
Call accountbillid 1
TEMP-accountbill
accountbill
ErrorAccountbill.txt
TEMP-accountbill
T-SQL
SQL
1
2T-SQL
1DDL selectupdatedeleteinsert
2DML createalterdrop
3DCL grantrevokedeny
T-SQL
select * from news
select bianhao,xingming from news
select distinct * from news
select top 3 * from news
select bianhao as from news
select id,title into new_news from news
where title=''
where title like '%%'
chenghu like '_'
telcode like '13[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
telcode like '13[^a-z][^a-z][^a-z][^a-z][^a-z][^a-z][^a-z][^a-z][^a-z]'
where riqi>='1992-01-01' and riqi<='1999-09-09'
where riqi>='1999-01-01' or riqi<='1991-09-09'
where riqi between '1992-01-01' and '1999-09-09'
where riqi is null
where riqi in('1992-01-01','1999-09-09')
where zhiwei <> ''
T-SQL
insert into news values(,'','','','')
insert into news(id,title) values(1,'')
insert into new_news(id,title) select id,title from news
T-SQL
update news set riqi='2009-09-09'
update news set title='' where id=5
update news set title='',riqi='2009-09-09' where id=5
T-SQL
delete from news
delete from news where id=5
truncate table news
0
Windows SQL
-- Ctrl+R
--1
select * from yuangong
--2
select * from yuangong
where sex=''
--3 AS ()
select name as ,bumen as
from yuangong
--4
select * from yuangong
where bumen<>''
--5 null
select * from yuangong
where bumen is null
--where bumen is not null
--6
--
select name as ,'' as
from yuangong where sex=''
--7 1993
select top 2 * from yuangong
where riqi>='1993-01-01'
order by riqi asc
----8 20%
select top 20 percent * from yuangong
order by age desc
--9
--
insert into yuangong
values(7,'','','','2011-03-03','',18)
--10///
insert into yuangong(bianhao,name,sex,zhiwei)
values(11,'','','')
--11
--
INSERT INTO (,,,)
SELECT bianhao,name,sex,zhiwei
FROM yuangong
WHERE sex=''
--12newyuangong
--
select * into newyuangong from yuangong
where sex=''
--13 yuangong newyuangong
--
--,
insert
select * from yuangong
union
select * from newyuangong
--14
update yuangong
set name=''
where name=''
update yuangong
set sex='',age=20
where name=''
--15
delete from yuangong
where name=''
--16
delete from yuangong