我正在努力通过a Java Tutorial。如何将这个MS SQL脚本重写为MySQL脚本?
作者写了教程来使用MS SQL。我想遵循使用MySQL的教程。我不完全知道如何翻译它采用“身份”,“约束”的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);
...但我担心的是,省略的代码将导致丢失的功能,甚至与本教程的其余部分不兼容。
有没有更好的方法我应该写这个?