简体   繁体   English

ORA-00903:无效的表名。 我不知道为什么

[英]ORA-00903: invalid table name. I don't know why

I want to create a table but i get this error. 我想创建一个表,但出现此错误。 I know the table does not exists. 我知道表格不存在。

create table Comenzi_Livrare
(ID_Comanda number(8),
CUI_Mag number(8),
ID_Client number(8),
data_comanda date,
constraint pk_ID_COMANDA primary key (ID_comanda),
constraint fk_cui_mag foreign key (CUI_Mag) references (Magazin),
constraint fk_ID_CLIENT foreign key (ID_Client) references (Clienti));

You need to specify both the table name and column name in the parent table of the foreign key relationships. 您需要在外键关系的父表中同时指定表名和列名。

As currently written, Magazin and Clienti are being interpreted as column names with a missing table name for each. 正如目前所写, MagazinClienti被解释为列名,每个列名都缺少表名。

I don't know the column names in the parent tables, but this example should help you: 我不知道父表中的列名,但是此示例应为您提供帮助:

create table Comenzi_Livrare
(
ID_Comanda number(8),
CUI_Mag number(8),
ID_Client number(8),
data_comanda date,
constraint pk_ID_COMANDA primary key (ID_comanda),
constraint fk_cui_mag foreign key (CUI_Mag) references Magazin (CUI),
constraint fk_ID_CLIENT foreign key (ID_Client) references Clienti (ID)
);

检查数据库中是否存在表: MagazinClienti ,因为Oracle不知道这些表,所以会发生此错误。

You might want to change the word "number" to int. 您可能需要将单词“ number”更改为int。

create table Comenzi_Livrare
(ID_Comanda int(8),
CUI_Mag int(8),
ID_Client int(8),
data_comanda date,
constraint pk_ID_COMANDA primary key (ID_comanda),
constraint fk_cui_mag foreign key (CUI_Mag) references (Magazin),
constraint fk_ID_CLIENT foreign key (ID_Client) references (Clienti));

you're missing table name on fk_cui_mag constraint 您在fk_cui_mag约束上缺少表名

it should be: 它应该是:

CONSTRAINT fk_column
    FOREIGN KEY (column1, column2, ... column_n)
    REFERENCES parent_table (column1, column2, ... column_n)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM