|
Posted by Tom Moreau on 04/16/06 01:35
Try the following code:
create table t
(
ID int primary key
, Col1 int not null
)
go
create view v
as
select * from t
go
insert v values (1, 2)
go
alter table t
add
Col2 int not null constraint CK_t default (0)
go
alter table t
drop constraint CK_t
go
select * from v
go
select * from t
go
insert v values (2, 2)
go
drop view v
drop table t
You'll see that the SELECT from the view did not pick up the extra column.
Also, the second insert failed - even though the SELECT on the view
suggested there were only 3 columns.
--
Tom
----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
"Peter" <someone@someplace.com> wrote in message
news:6850b$44417233$50394e09$25293@news.chello.nl...
People are telling me it is bad to put
select * from <atable>
in a view. I better should list all fields of the table inside the
definition of the view.
I dont know exactly why but some say:
A select * from makes sql server does a table scan.
Is that true, even if i put a where on the select on the view? And what if i
dont list all fields in the select on the view?
Thanks for the answer.
Peter
[Back to original message]
|