Sql语句~1

1。计算语句执行时间

declare @starttime as datetime,
@endtime as datetime
set @starttime =getdate()

select*from FourWord where windex=33333

set @endtime = getdate()
select @starttime as '开始时间',@endtime as '结束时间',datediff("ms",@starttime,@endtime)as '运行时间'
 
2.创建具有indentity属性的自增长的ID列

alter table vSingleWord add id int identity

3.删除名为windex的列

alter table TempWord drop column windex

 

4.选符合某些记录进另外一个记录

Insert into TableA Select *From TableB  where word like '天%'

5.挑出无重复的word列插入一个新建表KK

select distinct word into KK from SingleWord order by word

6。从两个表中挑选不同部分

select word from Allword where word not in (select word from sogouword)  and len(word)=3

7.给某个表的列设置unique属性

 ALTER   TABLE   Allword    
  ADD   CONSTRAINT   uq_a  
  UNIQUE(word)

 

你可能感兴趣的:(sql,table,insert)