如何针对数据库字段创建2选1必填的约束? 假设有数据库表A,包括3个字段X,Y,Z。其中X为主键必填,但Y和Z能且只能填其一,不能都填或都不填。该如何建立这种数据库约束? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 貌似没见过这种约束 不过通过instead of触发器是可以做到的。 当你插入或者更新的时候 去判断另外一个是否有值 去用别的语句代替执行 create table tmp(t_no varchar2(2),t_x varchar2(2),t_y varchar2(2),check( (t_x is null) and (t_y is not null)or(t_x is not null) and (t_y is null)) ) 少了2括号……^_^check( ((t_x is null) and (t_y is not null))or((t_x is not null) and (t_y is null))) 不用括 , and比or优先。 求一函数,有关字符串替换 ORA-00922: 选项缺失或无效 linux下tomcat的Oracle中文问题! For i in 20..80 loop(如何设置步长) 连接Oracle数据库问题????在线等 高手:求一Oracle SQL mySql 转Oracle 后number 精度问题,在线急!!!! 紧急求救:ORA-00093: shared_pool_reserved_size must be between 5000 and 8388608错误 导入导出时用到的参数文件应该放在哪地方? 服务应用程序 sql求助 多表查询语句不会写,各位帮忙下
(
t_no varchar2(2),
t_x varchar2(2),
t_y varchar2(2),
check( (t_x is null) and (t_y is not null)or(t_x is not null) and (t_y is null))
)
check( ((t_x is null) and (t_y is not null))or((t_x is not null) and (t_y is null)))