4、REPLACE选项。带ORREPLACE选项的CREATE语句格式为:CREATE OR REPLACE VIEWview_nameASSELECTcolumn_name(s)FROMtable_nameWHEREcondition这样在创建视图时,如果视图不存在,则创建它。如果已经存在一个同名的视图,那么先删除这个视图,然后再根据SELECT语句创建新视图,用这个新视图代替原来的视图。Intersect和Minusluxinfemale25tomfemale26mary1male27moneymale27tonymale28tony1m
5、ale19luxinfemale25tomfemale26mary2male27moneymale27tonymale28tony2male19TABLEA:TABLEB:SELECT*FROMTABLEAINTERSECTSELECT*FROMTABLEB;结果:NAME SEX AGE------------------------------luxinfemale25tomfemale26moneymale27tonymale28SELECT*FROMTABLEAMINUSSELECT*FRO
6、MTABLEB;结果:NAME SEX AGE------------------------------mary1 male 27tony1 male 19SELECT*FROMTABLEBMINUSSELECT*FROMTABLEA;结果:NAME SEX AGE------------------------------mary2 male 27to
7、ny2 male 19UNION、UNIONALL、INTERSECT和MINUS总结Union,对两个结果集进行并集操作,不包括重复行;UnionAll,对两个结果集进行并集操作,包括重复行;Intersect,对两个结果集进行交集操作,不包括重复行;Minus,对两个结果集进行差操作,不包括重复行。必须都有相同数目的字段,每个表相应字段的数据类型相同,可以在最后一个结果集中指定Orderby子句改变排序方式。