sql-server - 创建两个共享依赖关系的表
问题描述
我试图在 sql 中创建两个共享键的表,但我收到一条错误消息:在这种情况下,无法创建、删除、启用或禁用多个名为“PK_vc_Status”的约束、列、索引或触发器。不允许重复名称。
我对 mysqlServer 不是很有经验,我试图找出我的代码有什么问题。
CREATE TABLE vc_VidCast (
-- Columns for the VidCast table
vc_VidCastID int identity,
VidCastTitle varchar(50) not null,
StartDateTime datetime,
EndDateTime datetime,
ScheduleDurationMinutes int,
RecordingURL varchar(50),
vc_UserID int not null,
vc_StatusID int not null,
-- Constraints on the VidCast List table
CONSTRAINT PK_vc_VidCast PRIMARY KEY (vc_VidCastID),
CONSTRAINT FK1_vc_VidCast FOREIGN KEY (vc_UserID) REFERENCES vc_User(vc_UserID),
CONSTRAINT FK2_vc_VidCast FOREIGN KEY (vc_StatusID) REFERENCES vc_Status(vc_StatusID)
)
-- End creating the VidCast table
-- Creating the Status table
CREATE TABLE vc_Status (
-- Columns for the Status table
vc_StatusID int Identity,
StatusText varchar(20),
-- Constraints on the Status Table
CONSTRAINT PK_vc_Status PRIMARY Key (vc_StatusID),
CONSTRAINT U1_vc_Status UNIQUE (StatusText),
CONSTRAINT PK_vc_Status FOREIGN KEY (vc_StatusID) REFERENCES vc_VidCast(vc_StatusID)
)
-- End Creating The Status Table
解决方案
推荐阅读
- vba - MS Access 中的每个组合框都有一个功能
- sql - SQL - 拆分数据行并分配得分值
- mysql - 无法在树莓派上下载 MySQL 软件
- python-3.x - “布尔”对象不可下标 - Keras
- c# - SharpDevelop - 资源管理和访问问题
- jquery - Bootstrap 4 Wordpress - 工具提示不起作用
- javascript - 如何在catch块Nodejs中发送代码错误
- coldfusion - ColdFusion - 尝试将客户端变量存储在注册表中,即使设置为 Cookie?
- python - 从 Pandas 中的 UTC_TIME 系列获取星期几
- docker - Dockerfile:根目录上的 chmod 不起作用