有關sql簡單題目,有關SQl簡單題目

2022-03-11 13:38:10 字數 2600 閱讀 5926

1樓:騎檮杌的小哪吒

create table goods

(id int,

goodsname varchar(100),

unitprice int

)--4題

create trigger tr_goods_mod

on goods for update

asdeclare @unitprice int

declare @id int

select @id = id,@unitprice = unitprice from inserted

if @unitprice is not null

begin

update goodshouse set soldprice = @unitprice where goodid = @id

endgo

----------------------------------

--update goods set unitprice = 300 where id = 1

--1題

create trigger tr_goods_ins

on goods after insert

asdeclare @goodsid int

declare @goodsname varchar(100)

declare @unitprice int

select @goodsid = id,@goodsname = goodsname,@unitprice = unitprice

from inserted

insert into goodshouse values (@goodsid,0,@unitprice)

go----------------------------------------------

--insert into goods values(1,'transformers',250)

----select * from goodshouse

create table goodshouse

(id int identity(1,1),

goodid int,

stock int,

soldprice int

)create table solddetail

(id int,

goodsid int

)--2題

create trigger tr_solddetail_ins

on solddetail after insert

asdeclare @goodsid int

declare @id int

declare @stock int

select @goodsid = goodsid,@id = id

from inserted

select @stock = stock

from goodshouse

where goodid = @goodsid

if @stock > 0

begin

update goodshouse set stock = @stock - 1 where goodid = @goodsid

endelse

begin

print '貨物存貨不足!'

delete from solddetail where id = @id

endgo

create table department

(id int,

departmentname varchar(20)

)--insert into department values (1,'超人部門')

--3題

create trigger tr_department_del

on department for delete

asdeclare @id int

select @id = id from deleted

print @id

delete from employee where departmentid = @id

go-------------------------------------------

create table employee

(id int,

employeename varchar(10),

departmentid int

)--insert into employee values (1,'superman',1)

----insert into employee values (2,'spaiderman',1)

----insert into employee values (3,'speedman',1)

----delete from department where departmentname = '超人部門'

2樓:匿名使用者

creat trigger 觸發器名 on 觸發表名 with encryption

for (delete,insert,update) as sql_statements

有關極限的題目,有關極限的題目

其實求極限問題非常簡單!首先你要記住常見的等價替換形式,比如 x 0 x sinx tanx n次根號下 1 x 1 x n此外就是兩個最重要的 lim x 0 1 x 的1 x次 elim x 無窮大 1 1 x 的x次 e我已經很長時間沒看這方面的東西了,還有其它一些等價替換。上面的後面兩個實質...

怎麼提高這個很簡單的SQL的效能

1 新增合適的索引 2 優化sql語句 如何進行sql效能優化 進行sql效能優化的方法 1 sql語句不要寫的太複雜。一個sql語句要儘量簡單,不要巢狀太多層。2 使用 臨時表 快取中間結果。簡化sql語句的重要方法就是採用臨時表暫存中間結果,這樣可以避免程式中多次掃描主表,也大大減少了阻塞,提高...

關於資料庫SQL的一些簡單題

1.select 班級名稱,班級 from 班級 where 系部 02 or 系部 03 2.在 學生 表中查詢姓 李 學員的學號,姓名,年齡 3.在 讀者表 表中查詢名稱中含有 紅 的所有內容 5.select 姓名,年齡 from 教師 where 姓名 like 梅 4.在 圖書表 表中查詢...