我正在尝试做一个简单的数据库SQL脚本,我只需要创建一个数据库以及其中的4个表。到目前为止,我收到一个非常恼人的错误,指出:数据库中已经有一个名为'DEVICE_TYPE'的对象。为什么,我不知道?任何有关此事的帮助将受到高度赞赏。
请参阅以下代码:
DROP Database EliteShop
GO
CREATE Database EliteShop
GO
USE EliteShop
GO
CREATE TABLE DEVICE_TYPE
(
Device_TypeID INT IDENTITY(1,1),
Device_TypeID_Name VARCHAR(50),
CONSTRAINT pk_devicetype PRIMARY KEY(Device_TypeID)
)
CREATE TABLE MANUFACTURER
(
Manufacturer_Code VARCHAR(50),
Manufacturer_Description VARCHAR(100),
CONSTRAINT pk_manufacturercode PRIMARY KEY(Manufacturer_Code)
)
CREATE TABLE [PLATFORM]
(
PlatformID INT IDENTITY(1,1),
Platform_Description VARCHAR(50),
CONSTRAINT pk_platID PRIMARY KEY(PlatformID)
)
CREATE TABLE DEVICE
(
DeviceID INT IDENTITY(1,1),
Device_TypeID INT,
PlatformID INT,
Manufacturer_Code VARCHAR(50),
Model VARCHAR(50),
InternalMemory VARCHAR(10),
Price MONEY,
CONSTRAINT pk_deviceID PRIMARY KEY (DeviceID),
CONSTRAINT fk_deviceType FOREIGN KEY (Device_TypeID) REFERENCES DEVICE_TYPE(Device_TypeID),
CONSTRAINT fk_manuFCode FOREIGN KEY (Manufacturer_Code) REFERENCES MANUFACTURER(Manufacturer_Code),
CONSTRAINT fk_myPlatID FOREIGN KEY (PlatformID) REFERENCES [PLATFORM](PlatformID)
)