索引:
不用扫描整个表就实现对数据快速访问的途径。
二进制类型不支持索引
视图:
从一个或多个基本表中导出所显示的表,是没有数据的虚表。
多表出一视图,一表出多视图,多表与一视图出一视图
游标:
所有数据库:行的次序无关,列的次序无关
select Code,Name,Brand_Name,Prod_Name,oil,Price from car
join Brand on Car.Brand = Brand.Brand_Code
join Productor on Productor.Prod_Code = Brand.Prod_Code
select * from viewcar
select * from chinastates where parentareacode=‘37‘
create view ShanDong
as
select * from chinastates where parentareacode=‘37‘
go
select * from shandong
insert into shandong(areacode,areaname,parentareacode,root,zone) values(‘3779‘,‘临淄‘,‘38‘,‘‘,‘‘)
select * from viewcar
insert into viewcar values(‘c222‘,‘鲁轻电动汽车‘,‘超强续行王‘,‘山东轻骑‘,‘0‘,‘5‘)
declare cur_car cursor scroll
for select name from Car where Name like ‘奥迪%‘
open cur_car
fetch first from cur_car
while @@FETCH_STATUS = 0
begin
declare @name varchar(50)
fetch next from cur_car into @name
--print @name
if ltrim(left(@name,LEN(‘奥迪A4 07款‘)))=‘奥迪A4 07款‘
begin
fetch prior from cur_car into @name
print @name
fetch relative 2 from cur_car into @name
print @name
end
end
close cur_car
deallocate cur_car