ORA-00904:: identificatore non valida
Domanda
Sto cercando di creare una tabella in Oracle e ottenere l'errore: ORA-00904: : invalid identifier
Ecco il mio comando. Io davvero non riesco a vedere tutto il problema in esso. Please help me per identificare l'errore. Grazie.
CREATE TABLE Sale (
CustomerId INT NOT NULL ,
BarCode INT NOT NULL ,
SalesId INT NOT NULL ,
Date DATE NULL ,
CheckOut TINYINT(1) NULL ,
PRIMARY KEY (CustomerId, BarCode, SalesId) ,
CONSTRAINT fk_Customer_has_Product_Customer
FOREIGN KEY (CustomerId )
REFERENCES Customer (CustomerId )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT fk_Customer_has_Product_Product1
FOREIGN KEY (BarCode )
REFERENCES Product (BarCode )
ON DELETE NO ACTION
ON UPDATE NO ACTION);
Soluzione
Come detto in precedenza, il cambiamento "DATA" a qualcosa di più descrittivo e non riservato. Inoltre, sembra TINYINT non funziona in un tavolo di creare in modo che il cambiamento a numero (1), e un corretto suggerimento di Tony di ridurre le dimensioni nome (<= 30 chrs)
CREATE TABLE Sale
(
CustomerId INT NOT NULL ,
BarCode INT NOT NULL ,
SalesId INT NOT NULL ,
SaleDate DATE NULL , --DATE is reserved, changed to SaleDate
CheckOut number(1) NULL , --tinyint(1) did not work so changed to number(1)
PRIMARY KEY( CustomerId, BarCode, SalesId ) ,
CONSTRAINT fk_SaleCustCusID FOREIGN KEY( CustomerId ) REFERENCES Customer( CustomerId ) ON
DELETE NO ACTION ON
UPDATE NO ACTION,
CONSTRAINT fk_SaleCustBarCode FOREIGN KEY( BarCode ) REFERENCES Product( BarCode ) ON
DELETE NO ACTION ON
UPDATE NO ACTION
);
Altri suggerimenti
La lunghezza massima per un identificatore di Oracle è di 30 caratteri. Questi superino tale, sono lunghi 32 caratteri:
- fk_Customer_has_Product_Customer
- fk_Customer_has_Product_Product1
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow