我正在尝试通过Java Tutorial进行工作。
作者编写了使用 MS SQL 的教程。我想按照使用 MySQL 的教程进行操作。我不完全确定如何翻译使用“IDENTITY”、“CONSTRAINT”和“CLUSTERED”的 MS SQL 脚本,如下所示:
CREATE TABLE [event_person] (
[event_id] [int] NOT NULL,
[person_id] [int] NOT NULL,
CONSTRAINT [PK_event_person] PRIMARY KEY CLUSTERED
(
[event_id] ASC,
[person_id] ASC
)
)
CREATE TABLE [events] (
[id] [int] IDENTITY(1,1) NOT NULL,
[dt] [datetime] NULL,
[name] [nvarchar](50) NULL,
CONSTRAINT [PK_events] PRIMARY KEY CLUSTERED
(
[id] ASC
)
)
CREATE TABLE [people] (
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [varchar](50) NOT NULL,
CONSTRAINT [PK_people] PRIMARY KEY CLUSTERED
(
[id] ASC
)
)
据我所知,这是:
CREATE TABLE event_person (
event_id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
person_id int NOT NULL
);
CREATE TABLE events (
id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
dt datetime NULL,
name nvarchar(50) NOT NULL);
CREATE TABLE people (
id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
name nvarchar(50) NOT NULL);
...但我担心省略的代码会导致功能丢失,甚至与教程的其余部分不兼容。
有没有更好的方法我应该写这个?