ORA-00907: 在 oracle 上创建表时缺少右括号错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18972856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:56:50  来源:igfitidea点击:

ORA-00907: missing right parenthesis Error while creating a table on oracle

sqloracle

提问by Dinesh Soni

I am getting ORA-00907: missing right parenthesisError while creating a table on oracle

ORA-00907: missing right parenthesis在 oracle 上创建表时出现错误

here is what I did:

这是我所做的:

create table customers(
cust_num number(4),
company varchar2(20),
cust_rep number(3),
credit_limit number(15),
custraint cust_num_pk
primary key(cust_num));

whats wrong ??

怎么了 ??

回答by Sasanka Panguluri

There's nothing called Custraint. It's Constraint.

没有什么叫的Custraint。它是Constraint

It should be:

它应该是:

create table customers(
  cust_num number(4),
  company varchar2(20),
  cust_rep number(3),
  credit_limit number(15),
  constraint cust_num_pk primary key(cust_num)
);

回答by Sunil Khatri

Check your syntax, see the below statement works fine,

检查你的语法,看看下面的语句工作正常,

  create table customers( cust_num number(4), company varchar2(20),
  cust_rep number(3), credit_limit number(15), constraint cust_num_pk 
  primary key(cust_num));

回答by Aditya Kakirde

You can also create a primary key constraint like -

您还可以创建一个主键约束,如 -

create table customers( cust_num number(4) primary key, company varchar2(20), cust_rep number(3), credit_limit number(15));

This is called column-level constraint definition, while the ones in above posts are known as Table-level constraint definitions.

这称为列级约束定义,而上述帖子中的称为表级约束定义。

Both are correct.

两者都是正确的。