According to the sql standard the following is valid command:
CREATE TABLE Table_1 (
|
column_1 SMALLINT
|
CONSTRAINT constraint_1 CHECK(column_1<400),
|
column_2 CHAR(5));
|
Oracle grammar examples indicate the same:
CREATE TABLE employees_demo
|
( employee_id NUMBER(6)
|
, first_name VARCHAR2(20)
|
, last_name VARCHAR2(25)
|
CONSTRAINT emp_last_name_nn_demo NOT NULL
|
, email VARCHAR2(25)
|
CONSTRAINT emp_email_nn_demo NOT NULL
|
...
|
But both 10.2.6 and 10.3.0 show syntax error:
mysql> CREATE TABLE Table_1 (
|
-> column_1 SMALLINT
|
-> CONSTRAINT constraint_1 CHECK(column_1<400),
|
-> column_2 CHAR(5));
|
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT constraint_1 CHECK(column_1<400),
|
column_2 CHAR(5))' at line 3
|
- relates to
-
MDEV-7563
Support CHECK constraint as in (or close to) SQL Standard
-
-
Closed
{"report":{"fcp":889.3999999761581,"ttfb":234.89999997615814,"pageVisibility":"visible","entityId":61493,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"e265b374-62e5-4f25-9b9c-930654173734","navigationType":0,"readyForUser":1013.6999999284744,"redirectCount":0,"resourceLoadedEnd":1088.2999999523163,"resourceLoadedStart":240.39999997615814,"resourceTiming":[{"duration":133.19999992847443,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":240.39999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":240.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":373.59999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":133.20000004768372,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":240.69999992847443,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":240.69999992847443,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":373.89999997615814,"responseStart":0,"secureConnectionStart":0},{"duration":142.20000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":240.79999995231628,"connectEnd":240.79999995231628,"connectStart":240.79999995231628,"domainLookupEnd":240.79999995231628,"domainLookupStart":240.79999995231628,"fetchStart":240.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":240.79999995231628,"responseEnd":383,"responseStart":383,"secureConnectionStart":240.79999995231628},{"duration":219.69999992847443,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":241,"connectEnd":241,"connectStart":241,"domainLookupEnd":241,"domainLookupStart":241,"fetchStart":241,"redirectEnd":0,"redirectStart":0,"requestStart":241,"responseEnd":460.6999999284744,"responseStart":460.6999999284744,"secureConnectionStart":241},{"duration":225.20000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":241.29999995231628,"connectEnd":241.29999995231628,"connectStart":241.29999995231628,"domainLookupEnd":241.29999995231628,"domainLookupStart":241.29999995231628,"fetchStart":241.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":241.29999995231628,"responseEnd":466.5,"responseStart":466.5,"secureConnectionStart":241.29999995231628},{"duration":225.89999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":241.5,"connectEnd":241.5,"connectStart":241.5,"domainLookupEnd":241.5,"domainLookupStart":241.5,"fetchStart":241.5,"redirectEnd":0,"redirectStart":0,"requestStart":241.5,"responseEnd":467.39999997615814,"responseStart":467.39999997615814,"secureConnectionStart":241.5},{"duration":226.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":241.69999992847443,"connectEnd":241.69999992847443,"connectStart":241.69999992847443,"domainLookupEnd":241.69999992847443,"domainLookupStart":241.69999992847443,"fetchStart":241.69999992847443,"redirectEnd":0,"redirectStart":0,"requestStart":241.69999992847443,"responseEnd":468.2999999523163,"responseStart":468.2999999523163,"secureConnectionStart":241.69999992847443},{"duration":291.89999997615814,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":241.89999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":241.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":533.7999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":227.19999992847443,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":242,"connectEnd":242,"connectStart":242,"domainLookupEnd":242,"domainLookupStart":242,"fetchStart":242,"redirectEnd":0,"redirectStart":0,"requestStart":242,"responseEnd":469.1999999284744,"responseStart":469.1999999284744,"secureConnectionStart":242},{"duration":291.8000000715256,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":242.19999992847443,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":242.19999992847443,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":534,"responseStart":0,"secureConnectionStart":0},{"duration":227.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":242.39999997615814,"connectEnd":242.39999997615814,"connectStart":242.39999997615814,"domainLookupEnd":242.39999997615814,"domainLookupStart":242.39999997615814,"fetchStart":242.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":242.39999997615814,"responseEnd":469.89999997615814,"responseStart":469.89999997615814,"secureConnectionStart":242.39999997615814},{"duration":762.6999999284744,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":248.39999997615814,"connectEnd":248.39999997615814,"connectStart":248.39999997615814,"domainLookupEnd":248.39999997615814,"domainLookupStart":248.39999997615814,"fetchStart":248.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":248.39999997615814,"responseEnd":1011.0999999046326,"responseStart":1011.0999999046326,"secureConnectionStart":248.39999997615814},{"duration":764,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":248.39999997615814,"connectEnd":248.39999997615814,"connectStart":248.39999997615814,"domainLookupEnd":248.39999997615814,"domainLookupStart":248.39999997615814,"fetchStart":248.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":248.39999997615814,"responseEnd":1012.3999999761581,"responseStart":1012.3999999761581,"secureConnectionStart":248.39999997615814},{"duration":155.10000002384186,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":547.2999999523163,"connectEnd":547.2999999523163,"connectStart":547.2999999523163,"domainLookupEnd":547.2999999523163,"domainLookupStart":547.2999999523163,"fetchStart":547.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":547.2999999523163,"responseEnd":702.3999999761581,"responseStart":702.3999999761581,"secureConnectionStart":547.2999999523163},{"duration":211.79999995231628,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":831.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":831.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1043.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":251.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":832.5,"connectEnd":832.5,"connectStart":832.5,"domainLookupEnd":832.5,"domainLookupStart":832.5,"fetchStart":832.5,"redirectEnd":0,"redirectStart":0,"requestStart":832.5,"responseEnd":1083.5999999046326,"responseStart":1083.5999999046326,"secureConnectionStart":832.5},{"duration":275.7999999523163,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":882.8999999761581,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":882.8999999761581,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1158.6999999284744,"responseStart":0,"secureConnectionStart":0},{"duration":255.29999995231628,"initiatorType":"script","name":"https://jira.mariadb.org/s/f51ef5507eea4c158f257c66c93b2a3f-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":833,"connectEnd":833,"connectStart":833,"domainLookupEnd":833,"domainLookupStart":833,"fetchStart":833,"redirectEnd":0,"redirectStart":0,"requestStart":833,"responseEnd":1088.2999999523163,"responseStart":1088.2999999523163,"secureConnectionStart":833}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":20,"responseStart":235,"responseEnd":246,"domLoading":238,"domInteractive":1095,"domContentLoadedEventStart":1095,"domContentLoadedEventEnd":1158,"domComplete":1420,"loadEventStart":1420,"loadEventEnd":1421,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1059.3999999761581},{"name":"bigPipe.sidebar-id.end","time":1060.0999999046326},{"name":"bigPipe.activity-panel-pipe-id.start","time":1060.2999999523163},{"name":"bigPipe.activity-panel-pipe-id.end","time":1062.5999999046326},{"name":"activityTabFullyLoaded","time":1176.2999999523163}],"measures":[],"correlationId":"1222f5f6104bf1","effectiveType":"4g","downlink":9.4,"rtt":0,"serverDuration":155,"dbReadsTimeInMs":12,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Please note that SQL-99 is not a MariaDB manual, it's the standard, of which MariaDB only implements a subset. Here is the documentation of the feature syntax in current MariaDB: https://mariadb.com/kb/en/mariadb/constraint/
You can either have CHECK(expression) as a part of a column definition, or CONSTRAINT [constraint_name] CHECK (expression). The latter goes outside the column definition; the page doesn't say that, it should probably be added as an explicit note; it is indeed not implemented as a part of a column definition, which the example in the description is about. [NOT] DEFERRABLE is not implemented either.
I've converted it into a task.