如何强制 Oracle 数据库只允许在其中的任何 table 中插入 ASCII 字符?

How to enforce a Oracle DB to only allow insertion of ASCII chars in any table within it?

我在 Oracle DB 中有几个表,它们将包含通常数据的列,可以是字符串、数字、time/date 等。这里唯一的限制是,每当插入新数据时,它应该如果不是 ASCII,则抛出错误。

Oracle 中是否有这样的 attribute/property 可以保证我只处理 ASCII?

您可以为此创建一个检查约束:

alter table foo 
  add constraint check_ascii 
  check (asciistr(the_column) = the_column);

asciistr() 将 "escape" 所有非 ASCII 字符。因此,如果该函数的结果与包含非 ascii 字符的输入不同。