SQL CHECK statement error: A comma or a closing bracket was expected. (near "CHECK" )

296 Views Asked by At

I have made relational database model using MagicDraw tool. Every cashier has their workTime type saved in enumerator:

enter image description here enter image description here

Then I generate DDL code and try to paste it into phpMyAdmin to generate DB but I get many errors. I tried to fix them by hand but errors are still here. So how should that check statement be written?

SQL CHECK statement

Errors: Errors

2

There are 2 best solutions below

0
On BEST ANSWER

I think I have found a solution.

A book that I was following to create DDL from MagicDraw project suggested to pick "Check Constraints" as an "Enumeration transformation strategy" when transforming model. It didnt worked that way so I have chosen "Lookup tables" instead and DDL code seems to be working now.

However it still had some erorrs. I had to add semicolons after all INSERT statements. enter image description here

And I also had to delete word "precision" after every 'double' type: delete

It works now.

1
On

A check constraint isn't part of a column's definition, it's its own clause in the table definition. You need a comma between the worktime char(13) not null and the check.