有没有简单的方法可以根据条件删除表的非空约束

发布于 2025-01-09 05:16:21 字数 190 浏览 3 评论 0原文

如果 mty.bty_tp = GA 且 mty.geal_conds_vion_num 如 %36%,则应禁用各个表中的强制输入(非空约束)。

它涉及以下表格

· tbt_con.entry_dat

· tbt__texts

· tbt_amounts

· tbmt_currencies

If mty.bty_tp = GA and mty.geal_conds_vion_num like %36% then the mandatory input(not null constraints) in various tables should disabled.

It concerns the following tables

· tbt_con.entry_dat

· tbt__texts

· tbt_amounts

· tbmt_currencies

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小姐丶请自重 2025-01-16 05:16:21

你不能这样做,没有条件地作为约束(“按原样”)。

为了强制执行这一点,您需要

  • 使用数据库触发器,它将允许(或不允许)您将 NULL 值插入到某些列中,
  • 在前端应用程序中实现这一点,

我猜第一个选项是“更安全”,因为您不必事后关心它 - 数据库将防止无效插入。

它还意味着这些表中的列不应被创建为NOT NULL

You can't do that, not conditionally as a constraint ("as is").

In order to enforce that, you'll need to either

  • use a database trigger which will allow (or not) you to insert NULL values into certain columns
  • implement that in front-end application

I guess that the 1st option is "safer" as you don't have to take care about it afterwards - database will prevent invalid inserts.

It also means that columns in those tables should NOT be created as NOT NULL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文