如何为 Oracle 创建顺序 SQL 创建脚本?

发布于 2024-09-07 03:51:33 字数 238 浏览 1 评论 0原文

比如:

create table Employee(
ID int primary key,
Name nvarchar(200)
IDArea int foreign key references Area(ID)
);

go

create table Area(
ID int primary key,
Name nvarchar(200)
);

Oracle 中是否存在这样的东西?

Something like:

create table Employee(
ID int primary key,
Name nvarchar(200)
IDArea int foreign key references Area(ID)
);

go

create table Area(
ID int primary key,
Name nvarchar(200)
);

Does something like this exist in Oracle?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情未る 2024-09-14 03:51:33

是的,只需省略“GO”关键字并将语句放入文件中:

create table Area(
ID int primary key,
Name nvarchar2(200)
);

create table Employee(
ID int primary key,
Name nvarchar2(200),
IDArea int references Area(ID)
);

您必须在引用它的外键之前创建区域主键,因此我已经交换了它们。 Oracle 中的外键语法也略有不同。

Yes, just leave out the "GO" keywords and put the statements in a file:

create table Area(
ID int primary key,
Name nvarchar2(200)
);

create table Employee(
ID int primary key,
Name nvarchar2(200),
IDArea int references Area(ID)
);

You must create the Area primary key before the foreign key that references it, so I have swapped these around. Also the foreign key syntax is slightly different in Oracle.

纵山崖 2024-09-14 03:51:33

您应该首先创建主表,忘记 nvarchar 数据类型,最终脚本将是:

create table Area( 
ID number primary key, 
Name varchar2(200) 
); 

create table Employee( 
ID number primary key, 
Name varchar2(200) ,
IDArea number, constraint fk_idarea foreign key (idarea) references Area(ID) 
); 

You should first create the master table, forget nvarchar datatype, and eventually the script would be :

create table Area( 
ID number primary key, 
Name varchar2(200) 
); 

create table Employee( 
ID number primary key, 
Name varchar2(200) ,
IDArea number, constraint fk_idarea foreign key (idarea) references Area(ID) 
); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文