当前位置:网站首页>Ask a question about SQL view
Ask a question about SQL view
2022-06-24 13:03:00 【CSDN Q & A】
There is one sql But I don't know how to solve the problem , I hope someone can help me answer
The problem is :
Create a test table and corresponding view to check when you can insert . Cover the following : (1) The view does not contain non default NOT NULL And standard value ; (2) The view does not contain the entire primary key; (3) The view is based on... That spans two tables JOIN Inquire about ; (iv) The view contains a GROUP BY request
among 2 I don't know how to do it
Thank you first
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;
边栏推荐
- 脚本之美│VBS 入门交互实战
- How to do research on plant endophytes? Special topic on Microbiology
- 实现领域驱动设计 - 使用ABP框架 - 更新操作实体
- [2022 national tournament simulation] BigBen -- determinant, Du Jiao sieve
- what the fuck! I'm flattered. He actually wrote down the answers to the redis interview questions that big companies often ask!
- Making daily menu applet with micro build low code
- Cohere、OpenAI、AI21联合发布部署模型的最佳实践准则
- [log service CLS] Tencent cloud log service CLS accesses CDN
- Sms service sms
- Metamask项目方给Solidity程序员的16个安全建议
猜你喜欢

MySQL 外键影响

几种常见的DoS攻击

WPF from zero to 1 tutorial details, suitable for novices on the road

【2022国赛模拟】摆(bigben)——行列式、杜教筛
![[data mining] final review (sample questions + a few knowledge points)](/img/90/a7b1cc2063784fb53bb89b29ede5de.png)
[data mining] final review (sample questions + a few knowledge points)

Pycharm中使用Terminal激活conda服务(终极方法,铁定可以)

Brief introduction to cluster analysis

Several common DoS attacks

《回归故里》阅读笔记

go Cobra命令行工具入门
随机推荐
[data mining] final review (sample questions + a few knowledge points)
Leetcode 1218. Longest definite difference subsequence
Brief introduction to cluster analysis
CVPR 2022 | interprétation de certains documents de l'équipe technique de meituan
《回归故里》阅读笔记
A hero's note stirred up a thousand waves across 10 countries, and the first-line big factories sent people here- Gwei 2022 Singapore
LVGL库入门教程 - 颜色和图像
Making daily menu applet with micro build low code
IIS WCF 808 port service access exception
Use abp Zero builds a third-party login module (I): Principles
YOLOv6:又快又准的目标检测框架开源啦
【2022国赛模拟】摆(bigben)——行列式、杜教筛
关于被黑数据库那些事
我开导一个朋友的一些话以及我个人对《六祖坛经》的一点感悟
Configuration (enable_*) parameter related to execution plan in PG
一文理解OpenStack网络
What should I do if I fail to apply for the mime database? The experience from failure to success is shared with you ~
Dingding, Feishu, and enterprise wechat: different business approaches
Several common DoS attacks
"Interesting" is the competitiveness of the new era