oracle 创建时缺少关键字 table
oracle missing keyword when creating table
我正在尝试在 oracle 中使用 sql 创建一个 table。但是使用这个语句它给了我缺少关键字错误。但它在 w3school sql tryit 编辑器中运行良好。任何人都可以帮助我了解导致 oracle 问题的原因吗?
create table products (product_key number(4) not null primary key, product_name varchar(50) not null unique, price_reg double(1000,2) not null, price_spec double(1000,2) not null, sell_reg double(1000,2) not null, sell_spec double(1000,2) not null)
我们将不胜感激。
您的问题是 Oracle 具有双精度数据类型和数字数据类型。您正在将两者结合起来。这里的"missing keyword"就是double后面的"precision"这个词。你要么想要这个:
create table products (
product_key number(4) not null primary key,
product_name varchar(50) not null unique,
price_reg double precision not null,
price_spec double precision not null,
sell_reg double precision not null,
sell_spec double precision not null)
或者这个:
create table products (
product_key number(4) not null primary key,
product_name varchar(50) not null unique,
price_reg numeric(10,2) not null,
price_spec numeric(10,2) not null,
sell_reg numeric(10,2) not null,
sell_spec numeric(10,2) not null)
另请注意,1000 不是数字类型的有效精度值,最大值为 38(我在上面使用了 10)。
尽量不要用w3school用oracle docs
已经给出答案
这里有一些有用的信息
- 表格的单数名称
- 列的单数名称
- 表前缀的架构名称(例如:SchemeName.TableName)
- 帕斯卡大小写(a.k.a。驼峰式大小写)
create table Product (
product_key number(4) not null primary key,
product_name varchar(50) not null unique,
price_reg double precision not null,
price_spec double precision not null,
sell_reg double precision not null,
sell_spec double precision not null)
我正在尝试在 oracle 中使用 sql 创建一个 table。但是使用这个语句它给了我缺少关键字错误。但它在 w3school sql tryit 编辑器中运行良好。任何人都可以帮助我了解导致 oracle 问题的原因吗?
create table products (product_key number(4) not null primary key, product_name varchar(50) not null unique, price_reg double(1000,2) not null, price_spec double(1000,2) not null, sell_reg double(1000,2) not null, sell_spec double(1000,2) not null)
我们将不胜感激。
您的问题是 Oracle 具有双精度数据类型和数字数据类型。您正在将两者结合起来。这里的"missing keyword"就是double后面的"precision"这个词。你要么想要这个:
create table products (
product_key number(4) not null primary key,
product_name varchar(50) not null unique,
price_reg double precision not null,
price_spec double precision not null,
sell_reg double precision not null,
sell_spec double precision not null)
或者这个:
create table products (
product_key number(4) not null primary key,
product_name varchar(50) not null unique,
price_reg numeric(10,2) not null,
price_spec numeric(10,2) not null,
sell_reg numeric(10,2) not null,
sell_spec numeric(10,2) not null)
另请注意,1000 不是数字类型的有效精度值,最大值为 38(我在上面使用了 10)。
尽量不要用w3school用oracle docs
已经给出答案
这里有一些有用的信息
- 表格的单数名称
- 列的单数名称
- 表前缀的架构名称(例如:SchemeName.TableName)
- 帕斯卡大小写(a.k.a。驼峰式大小写)
create table Product (
product_key number(4) not null primary key,
product_name varchar(50) not null unique,
price_reg double precision not null,
price_spec double precision not null,
sell_reg double precision not null,
sell_spec double precision not null)