Lab 4
Lab 4
Lab 4
--creare tabele
----------------------------------------------------------------------------
Create Table Ta(coda INT Identity Primary Key, a2 INT UNIQUE, a3 INT);
Create Table Tc(codc INT Identity Primary Key, coda INT Foreign Key REFERENCES
Ta(coda), c3 INT);
select*from Ta;
select*from Tc;
--populare tabel Ta
----------------------------------------------------------------------------
GO
CREATE PROCEDURE addValuesTa
AS
BEGIN
DECLARE @coda INT
Set @coda = 1
WHILE @coda <= 5000
BEGIN
INSERT INTO Ta(a2,a3) VALUES (@coda, @coda + 10);
SET @coda= @coda+1;
Print @coda
END;
END;
EXEC addValuesTa ;
SELECT * FROM Ta;
--populare tabel Tc
----------------------------------------------------------------------------
GO
CREATE PROCEDURE addValuesTc
AS
BEGIN
Set @LowerLimitForCoda = 1
Set @UpperLimitForCoda = 5000
Set @LowerLimitForC3 = 70
Set @UpperLimitForC3 = 2500
GO
select*from Tc order by coda;
select*from Tc order by codc;
SELECT *
FROM sys.indexes
WHERE object_id = OBJECT_ID('Ta')
Select *
from Tc inner join Ta
on Tc.coda = Ta.coda
Select *
from Tc inner join Ta
on Tc.coda = Ta.coda
where Tc.coda = 1999
Select *
from Tc inner join Ta
on Tc.coda = Ta.coda
where Tc.coda = 1999