简体   繁体   中英

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.

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.

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

it should be:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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