How to create check constraint in mysql diagram view?
Asked Answered
F

1

6

Lets say I have a table like this:

CREATE TABLE IF NOT EXISTS 
newbook_mast (book_id varchar(15) NOT NULL UNIQUE,          
book_name varchar(50)  ,           
isbn_no varchar(15)  NOT NULL UNIQUE  ,           
cate_id varchar(8)  ,             
aut_id varchar(8) ,             
pub_id varchar(8) ,            
dt_of_pub date ,             
pub_lang varchar(15) ,           
no_page decimal(5,0)            
book_price decimal(8,2) ,             
PRIMARY KEY (book_id)               
);

If I wanted to add a check on a column I would simply write :

CHECK(no_page>0) 

But instead of writing the code I am creating diagram models in the mysql workbench. I am unable to find how I can add a check like above by just using the diagram model?

Is it possible?

Fillander answered 8/4, 2020 at 17:46 Comment(0)
S
7

MySQL Workbench as of at least version 8.0.19 does not support CHECK constraints in navigator, table editor, or diagrams.

This has been reported as a missing feature:

https://bugs.mysql.com/bug.php?id=95143 No support for CHECK constraints in Workbench

You should log into the bugs site and click the "Affects Me" button on that bug.

Striptease answered 8/4, 2020 at 17:56 Comment(6)
Well at least i can stopp questioning my eye-sight. Thanks for this!Fillander
Has something changed in the last year? still looking for it.Attenuate
I assume if they had fixed it, then the bug I linked to would be closed, and there would be a comment indicating which version of MySQL Workbench it had been fixed in.Striptease
On the other hand, I upgraded to MySQL Workbench 8.0.22 and it seems it now recognizes CHECK constraints.Striptease
Yes, the last version recognizes them. But as I can see, there is still no way to implement them "automatically" while creating the eer model diagram, it is necessary to add them manually in the codeAttenuate
Well, as they say, "pull requests welcome." If you want it fixed, write the fix yourself, sign the contributor license agreement, and send them your code.Striptease

© 2022 - 2024 — McMap. All rights reserved.