mysql - MariaDB 约束中的 INITCAP
问题描述
我目前正在尝试在 MariaDB 中创建一个约束,检查每个空格后是否有一个大写字母(只是为了检查人名的正确格式)并且我尝试过使用 INITCAP 但它不允许我在检查中执行. 你能帮我做吗?
pepe Antonio -> It shouldn't go in
Pepe antonio -> It shouldn't go in
Pepe Antonio -> It should go in
解决方案
您可以使用:
name not regexp binary '(^| )[[:lower:]]'
这是一个 db<>fiddle。
这binary
是因为较新版本的 MariaDB 具有不区分大小写的正则表达式匹配。而且您显然很关心案例。
这是如何运作的:
'(^| )[[:lower:]]'
--^ beginning of string
----^ space
-----^ expression has either one
------^ followed by a lower-case character
当然,这是你不想要的。因此,NOT REGEXP
.
推荐阅读
- ssl-certificate - 如何仅为将在 .jks 文件中过期的证书创建 .csr 文件
- c++ - 声明一个空的析构函数会阻止编译器调用 memmove() 来复制连续的对象
- r - 如何在 R Shiny 应用程序中下载 PowerPoint 文件?
- google-calendar-api - 在 webforms 应用程序中使用 ASP.NET C# 在我的日历上添加/更新事件
- iar - IAR是否兼容Win10
- javascript - 获取 html 文件而不是获取 json 并创建 html 会很糟糕吗?为什么?
- macos - 在 macos 10.13.6 上安装 Bazel 0.16.1 时权限被拒绝
- apache-spark - Spark 中的迭代 RDD/Dataframe 处理
- javascript - 路由器 click.native 在 Vue 中传递了错误的参数
- r - 无法让 R 读取 GPS 坐标