当前位置:网站首页>问个sql view的问题
问个sql view的问题
2022-06-24 12:37:00 【CSDN问答】
有个sql问题但是不怎么懂怎么解, 希望有人帮我解答一下
问题是:
创建一个测试表和相应的视图以检查何时可以在视图中插入。 涵盖以下情况: (1) 视图不包含非默认 NOT NULL 和标准值; (2) 视图不包含整个primary key; (3) 视图基于跨越两个表的 JOIN 查询; (iv) 视图包含一个 GROUP BY 请求
其中2 不知道知道怎么弄
在这里先谢谢大家了
IF OBJECT_ID(N'Abt')is NULL
CREATE TABLE Abt (ANr int PRIMARY KEY, AbtName VARCHAR(20));
IF OBJECT_ID(N'Pers')is NULL
CREATE TABLE Pers (PNr int PRIMARY KEY, PName VARCHAR(40),AbtNrFK int);
ALTER TABLE Pers WITH CHECK ADD FOREIGN KEY(AbtNrFK)
REFERENCES Abt (ANr);
DELETE FROM Abt;
INSERT INTO Abt VALUES (1,'Einkauf');
INSERT INTO Abt VALUES (2,'Verkauf');
INSERT INTO Abt VALUES (3,'Vertrieb');
INSERT INTO Abt VALUES (4,NULL);
DELETE FROM Pers;
INSERT INTO Pers VALUES (1,'Mike Gent',3);
INSERT INTO Pers VALUES (2,'Alex Müller',2);
INSERT INTO Pers VALUES (3,'Leo Bauer',1);
INSERT INTO Pers VALUES (4,'Lena Bauer',2);
INSERT INTO Pers VALUES (5,'SARA Black',4);
INSERT INTO Pers VALUES (6,'David Simon',NULL);
INSERT INTO Pers VALUES (NULL,'Sam Schwarz',3);
CREATE VIEW TEST AS
SELECT PNr,PName,ANr,AbtName
FROM Pers join Abt on ANr=AbtNrFK
GROUP BY PNr,PName,AbtName;
边栏推荐
- [data mining] final review (sample questions + a few knowledge points)
- How to configure the national standard platform easygbs neutral version?
- 几种常见的DoS攻击
- Sms service sms
- About the hacked database
- [tke] GPU node NVIDIA Tesla driver reinstallation
- Another prize! Tencent Youtu won the leading scientific and technological achievement award of the 2021 digital Expo
- Troubleshooting and optimization of files that cannot be globally searched by ordinary users in easydss video platform customization project
- Interesting erasure code
- go Cobra命令行工具入门
猜你喜欢

手把手教你用AirtestIDE无线连接手机!

【数据库】期末复习(计科版)

LVGL库入门教程 - 颜色和图像

Who said that "programmers are useless without computers? The big brother around me disagrees! It's true

Parti,谷歌的自回归文生图模型

使用 Abp.Zero 搭建第三方登录模块(一):原理篇

Mlife forum | microbiome and data mining

Reading notes of returning to hometown

"Interesting" is the competitiveness of the new era

华为AppLinking中统一链接的创建和使用
随机推荐
About me, a 19 line programmer
Making daily menu applet with micro build low code
A good habit that makes your programming ability soar
用一个软件纪念自己故去的母亲,这或许才是程序员最大的浪漫吧
MySQL 外键影响
How to configure the national standard platform easygbs neutral version?
"I, an idiot, have recruited a bunch of programmers who can only" Google "
Remote terminal RTU slope monitoring and early warning
About Adobe Photoshop adjusting selection
WPF从零到1教程详解,适合新手上路
Tencent security monthly report - zero trust development trend forum, digital Expo Technology Award, Mercedes Benz security research results
what the fuck! I'm flattered. He actually wrote down the answers to the redis interview questions that big companies often ask!
A "full cloud" journey of a quasi financial system
Attack Science: DDoS (Part 2)
Interesting erasure code
实现领域驱动设计 - 使用ABP框架 - 创建实体
Reset the password, and the automatic login of the website saved by chrome Google browser is lost. What is the underlying reason?
The pod is evicted due to insufficient disk space of tke node
我开导一个朋友的一些话以及我个人对《六祖坛经》的一点感悟
Essential key steps in the construction of e-commerce live broadcast source code