我将 MySQL 表转换为 SQL Server,但出现以下错误
消息 156,级别 15,状态 1,第 762 行
关键字“ADD”附近的语法不正确。
我的脚本:
ALTER TABLE [Appointments]
ADD PRIMARY KEY ([Appointment_Id]),
ADD KEY User_Id ([User_Id]),
ADD KEY Status ([Appointment_Status]),
ADD KEY Availability_Id ([Availability_Id]);
假设您正在尝试在列 Appointment_Id 上创建主键,并且其他列可能是主键的一部分????(不要看起来像外键):
如果所有的都是主键的一部分:
Alter Table Appointments
add constraint [MyAppointmentConstraint]
on Appointments Primary Key (Appointment_Id, User_Id, Appointment_Status, Availability_Id);
或者,如果有些是外键:
Alter Table Appointments
add constraint [MyAppointmentConstraint]
Primary Key (Appointment_Id)
Alter Table Appointments
add foreign key (User_Id) references Users (UserId);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句