<!--打赏 End-->

创建数据库表

选中数据库,可编程性,类型,用户自定义数据类型,增加

删除

use test 
go
exec sp_addtype phonecall, 'char(11)','not null'
go

use test
go
exec sp_droptype 'phonecall'
go
View Code
alter table student2 --with nocheck
 add 
constraint pk_student2 primary key --nonclustered 
(number,name)
exec sp_help aa
exec sp_help
View Code
create table stu(name int not null)
sp_help stu

alter table stu
 add briday smalldatetime null

 alter table stu
  alter column briday datetime

  alter table stu
  drop column briday

  sp_rename 'stu.briday','出生日期1'--,'column'

  drop table stu
View Code
create table stu(
id int not null identity(1,1) primary key,
name nvarchar(20) null,
briday datetime null
)

--drop table stu 
sp_help stu

declare @i int;
set @i=1;
while @i<=20
begin 
 insert stu(name,briday) values('aa'+cast(@i as varchar(10)),getdate()); --convert(varchar(10),@i)
 set @i=@i+1;
end
View Code

 select top 10 percent  *  from 

distinct  , in, between and ,  is null

select * from student where name like '[王李】_'

select  * into student from stu    --创建表并插入数据

sum avg max min count

select 学号,avg(成绩) as '平均分' from student group by 学号 having avg(成绩)>=90

select 学号 from student where 成绩>=90 group by 学号 having count(*)>3

inner join 或join  a,b where  ;      left outer join 或 left join  ; right outer join 或 right join ; full join ; cross join 没有条件,没有where; student a join student b on a.姓名=b.姓名 ;

delete from ksmd  以物理方式一次删除一行,并在事务日志中记录每个删除的行

truncate table lqxx 通过释放存储表数据所用的数据也来删除,并只在事务日志记录页的释放

posted @ 2017-11-26 00:28  mikefts  阅读(118)  评论(0编辑  收藏  举报