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, 
);
有帮助吗?

解决方案

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 
);

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top