Question

Hello I have an issue with line 8 something to do with decimal.

any suggestions?

CREATE TABLE car (
cid         CHAR(8)                     PRIMARY KEY,
reg_no      VARCHAR(9)                  NOT NULL,
colour      VARCHAR(15)                 NOT NULL,
maker       VARCHAR(20)                 NOT NULL,
model       VARCHAR(20)                 NOT NULL,
fuel_type   CHAR(6) CHECK((fuel_type IN ('petrol', 'diesel'), 
eng_size    DECIMAL(2,1)                        NOT NULL,
owner       CHAR(6)                     NOT NULL,

FOREIGN KEY (owner) REFERENCES client (client_no)
                ON DELETE CASCADE   
                                ON UPDATE CASCADE, 
);
Était-ce utile?

La solution

your '))' were missing at the end of 8th line, and you had an extra ',' at the end before ).

This is fixed version

        CREATE TABLE car (
cid         CHAR(8)                     PRIMARY KEY,
reg_no      VARCHAR(9)                  NOT NULL,
colour      VARCHAR(15)                 NOT NULL,
maker       VARCHAR(20)                 NOT NULL,
model       VARCHAR(20)                 NOT NULL,
fuel_type   CHAR(6) CHECK((fuel_type IN ('petrol', 'diesel'))), 
eng_size    DECIMAL(20,15)              NOT NULL,
owner       CHAR(6)                     NOT NULL,

FOREIGN KEY (owner) REFERENCES client (client_no)
                ON DELETE CASCADE   
                                ON UPDATE CASCADE 
);

Autres conseils

The line before eng_size field declaration missing closing parenthesis )

Change it from

fuel_type   CHAR(6) CHECK((fuel_type IN ('petrol', 'diesel'),

To

fuel_type   CHAR(6) CHECK(fuel_type IN ('petrol', 'diesel')),

Also, remove the , from the last line

FOREIGN KEY (owner) REFERENCES client (client_no)
                ON DELETE CASCADE ON UPDATE CASCADE

See a successful fiddle here

http://sqlfiddle.com/#!15/841fd

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top