CREATE RULE,WHERE子句和CASE WHEN可以实现多种条件吗?

时间:2015-02-03 17:48:34

标签: postgresql postgresql-9.4

有一张名为; “名字”。我有更多的表:“names_a,names_,names_c .... names_z”。 “names_a ... names_z”中的表继承自“names”

我可以定义这样的规则:

Create RULE names_insert AS 
    On Insert To names WHERE (isim like 'A%') 
        Do Instead 
        Insert Into names_a VALUES(NEW.*) ;

我的问题是;我可以创建类似这样的规则:

Create RULE names_insert AS 
    On Insert To names 
    WHERE (isim like 'A%') 
        Do Instead 
        Insert Into names_a VALUES(NEW.*)
    WHERE (isim like 'B%') 
        Do Instead 
        Insert Into names_b VALUES(NEW.*) ;
    WHERE (isim like 'C%') 
        Do Instead 
        Insert Into names_c VALUES(NEW.*) ;
......

或者我必须创建一个触发器或函数吗?

...谢谢

0 个答案:

没有答案