Cno char (6),
Grade Smallint,
Year char (4),
Primary key (sno, cno, year),
FOREIGN KEY REFERENCES (sno) s (sno) on delete cascade,
FOREIGN KEY REFERENCES (cno) course (cno) on delete cascade,
CHECK ((grade IS NULL) OR (grade BETWEEN 0 AND 100))
);
The create view View_80 as select sno, cno, grade from sc where sc. Grade> 80 with check option
Insert into View_80
Values (' 08300010 ', '801', 87)
Error:
Message 515, level 16, state 2, line 127
Can't insert the value NULL columns' year ', 'master. The dbo. Sc' table; Column that allows Null values, the INSERT fails,
CodePudding user response:
Two ways:1, on the view to establish "alternative to trigger"
2, to field a default value,
CodePudding user response:
A view is a select statement, it is not a real store data, should be to give scthe table to insert dataInsert into sc (sno, cno, grade)
Values (' 08300010 ', '801', 87).