///sql查询分析器里面操作
///删除视图
if exists(select table_name from information_schema.views where table_name='v_user')
drop view v_user
///创建视图
create view v_user
as
select * from Userinfo
///修改视图
alter view v)user
as
select uname,uage from Userinfo
///创建触发器
create trigger Ulog
on Userinfo --对Userinfo 进入插入时触发
for insert --,update,delete
as
declare @uname nvarchar(20)
declare @id bigint
select @id=ID from inserted --查询用户编号
select @uname=uname from Userinfo where Id=@id--查询用户姓名
begin
INSERT INTO Userlog (info,itime) values('添加新的用户['+@uname+']!',getdate()) --插入到Userlog
end
///删除触发器
drop trigger Ulog