question

blackBoxCoder avatar image
blackBoxCoder asked

MySql constraint check like syntax error

Im working on a simlple library database system in oracle sql developer. I tried to re-use my sql code in my xamp server and the mariadb database used by xammp ran into errors that i couldnt understand. The sql code works as expected in sql developer. It checks that the mobile column contains a digit from 0-9 ![alt text][2] ![alt text][1] [1]: /storage/temp/4383-untitled2.jpg [2]: /storage/temp/4382-untitled.jpg
mysqloracle-sql-developer
untitled.jpg (168.3 KiB)
untitled2.jpg (200.2 KiB)
2 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

This is a Microsoft SQL Server forum, so you may be best posting on a forum specific for your platform. But looking at the error, it may be down to you using password as a column which is a reserved word, have you tried escaping that column name.
0 Likes 0 ·
@blackBoxCoder Also, there is no support for CHECK constraints in MySQL as of versions before and including 5.7. [MySQL documentation for 5.7][1] clearly states that "***The CHECK clause is parsed but ignored by all storage engines***" so there is no point in creating the constraint anyway. Since MariaDB is a branch of MySQL, it is possible that it does not support CHECK constraints either. The problem pointed out by @anthony.green is very valid. For me it is impossible to understand what possesses people to use the keywords for column names. Just because it is possible to create a table named **select** or **where** or a column named **date** or **password** provided that the name is wrapped in brackets does not necessarily mean that it is a good idea to do so. I understand that the incidence rate of keywords used as object names is pretty high, it is just hard to understand why. [1]: https://dev.mysql.com/doc/refman/5.7/en/create-table.html
0 Likes 0 ·

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.