当前位置:网站首页>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;
边栏推荐
- Sms service sms
- Istio practical skills: using prism to construct multi version test services
- MySQL foreign key impact
- 生成 4维 的 气压温度的 nc文件,之后进行代码读取(提供代码)
- Metamask项目方给Solidity程序员的16个安全建议
- J'a i ouvert quelques mots d'un ami et quelques réflexions personnelles sur le livre des six ancêtres
- DTU上报的数据值无法通过腾讯云规则引擎填入腾讯云数据库中
- Implement Domain Driven Design - use ABP framework - create entities
- CVPR 2022 | 美团技术团队精选论文解读
- How to do research on plant endophytes? Special topic on Microbiology
猜你喜欢

Yolov6: the fast and accurate target detection framework is open source

Concept + formula (excluding parameter estimation)

Teach you how to use airtestide to connect your mobile phone wirelessly!

CVPR 2022 | 美团技术团队精选论文解读

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

Nifi from introduction to practice (nanny level tutorial) - environment

Babbitt | metauniverse daily must read: 618 scores have been announced. How much contribution has the digital collection made behind this satisfactory answer

MySQL 外键影响

"Interesting" is the competitiveness of the new era

Understanding openstack network
随机推荐
Summary of the process of restoring damaged data in MySQL database
LVGL库入门教程 - 颜色和图像
Getting started with the go Cobra command line tool
1. Snake game design
短信服务sms
《回归故里》阅读笔记
【2022国赛模拟】摆(bigben)——行列式、杜教筛
Making daily menu applet with micro build low code
Use the open source tool k8tz to gracefully set the kubernetes pod time zone
105. 简易聊天室8:使用 Socket 传递图片
99% of the students can't write good code because of this problem!
Several common DoS attacks
“有趣” 是新时代的竞争力
一文讲透植物内生菌研究怎么做 | 微生物专题
How do websites and we media tap user needs? Deeply expose the secrets behind the keywords!
线程同步的基石AbstractQueuedSynchronizer详解
【数据挖掘】期末复习(样卷题目+少量知识点)
About the hacked database
我从根上解决了微信占用手机内存问题
1、贪吃蛇游戏设计