oracle中sql语句建表的时候check约束要使用自定义的函数,怎么用
2个回答
展开全部
参考 Oracle 的文档:
Application Developer's Guide - Fundamentals
6 Maintaining Data Integrity in Application Development
Restrictions on CHECK Constraints
A CHECK integrity constraint requires that a condition be true or unknown for every row of the table. If a statement causes the condition to evaluate to false, then the statement is rolled back. The condition of a CHECK constraint has the following limitations:
The condition must be a boolean expression that can be evaluated using the values in the row being inserted or updated.
The condition cannot contain subqueries or sequences.
The condition cannot include the SYSDATE, UID, USER, or USERENV SQL functions.
The condition cannot contain the pseudocolumns LEVEL, PRIOR, or ROWNUM.
The condition cannot contain a user-defined SQL function.
请注意那关键的一句:
The condition cannot contain a user-defined SQL function.
CHECK 的内容, 不能包含一个用户自定义的函数。
你可以尝试使用触发器来处理这个问题。
Application Developer's Guide - Fundamentals
6 Maintaining Data Integrity in Application Development
Restrictions on CHECK Constraints
A CHECK integrity constraint requires that a condition be true or unknown for every row of the table. If a statement causes the condition to evaluate to false, then the statement is rolled back. The condition of a CHECK constraint has the following limitations:
The condition must be a boolean expression that can be evaluated using the values in the row being inserted or updated.
The condition cannot contain subqueries or sequences.
The condition cannot include the SYSDATE, UID, USER, or USERENV SQL functions.
The condition cannot contain the pseudocolumns LEVEL, PRIOR, or ROWNUM.
The condition cannot contain a user-defined SQL function.
请注意那关键的一句:
The condition cannot contain a user-defined SQL function.
CHECK 的内容, 不能包含一个用户自定义的函数。
你可以尝试使用触发器来处理这个问题。
展开全部
public class Student{//主方法
public String name ;
public String id;
public Student(String na,String id){
this.name=na;
this.id=id;
}
public void dispStu(){
System.out.println("学生姓名是:"+this.name);
System.out.println("学生学号是:"+this.id);
}
================================================================
import javax.swing.JOptionPane;
public class Test{
public static void main(String args[]){ Student stu[]=new Student[5];
for(int i=0;i<stu.length;i++){ String strN=JOptionPane.showInputDialog("请输入第"+(i+1)+"个学生姓名"); //定义字符串strN
String strId=JOptionPane.showInputDialog("请输入第"+(i+1)+"个学生学号"); //定义字符串strId
}
for(int i=1;i<stu.length;i++){//
for(int k=0;k<stu.length-i;k++){//
if(stu[k].totalS<stu[k+1].totalS){//
Student temp =null;//
temp = stu[k];
stu[k]=stu[k+1];
stu[k+1]=temp;
}
}
}
for(int i=0;i<stu.length;i++){//
stu[i].setPai(i+1);
}
for(int i=0; i<stu.length;i++){//
stu[i].dispStu();
}
}
}
public String name ;
public String id;
public Student(String na,String id){
this.name=na;
this.id=id;
}
public void dispStu(){
System.out.println("学生姓名是:"+this.name);
System.out.println("学生学号是:"+this.id);
}
================================================================
import javax.swing.JOptionPane;
public class Test{
public static void main(String args[]){ Student stu[]=new Student[5];
for(int i=0;i<stu.length;i++){ String strN=JOptionPane.showInputDialog("请输入第"+(i+1)+"个学生姓名"); //定义字符串strN
String strId=JOptionPane.showInputDialog("请输入第"+(i+1)+"个学生学号"); //定义字符串strId
}
for(int i=1;i<stu.length;i++){//
for(int k=0;k<stu.length-i;k++){//
if(stu[k].totalS<stu[k+1].totalS){//
Student temp =null;//
temp = stu[k];
stu[k]=stu[k+1];
stu[k+1]=temp;
}
}
}
for(int i=0;i<stu.length;i++){//
stu[i].setPai(i+1);
}
for(int i=0; i<stu.length;i++){//
stu[i].dispStu();
}
}
}
追问
我想问的是在oracle的建表sql语句中加入check约束时调用的函数方法
不过谢谢你的回答,因为在java中,这个我也要用的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询