PostgreSQL的分区表建立(2)
来源:未知 责任编辑:责任编辑 发表时间:2014-01-25 11:38 点击:次
inherits(parent_table);
3.创建触发器函数
CREATE OR REPLACE FUNCTION test.tri_parent_tab_insert()
RETURNS TRIGGER AS $$
--author: kenyon
--created:2012-05-24
BEGIN
IF ( NEW.create_time >= DATE '2012-01-01' AND
NEW.create_time < DATE '2012-02-01' ) THEN
INSERT INTO test.parent_table_2012_01 VALUES (NEW.id,NEW.name,NEW.create_time);
ELSIF ( NEW.create_time >= DATE '2012-02-01' AND
NEW.create_time < DATE '2012-03-01' ) THEN
INSERT INTO test.parent_table_2012_02 VALUES (NEW.id,NEW.name,NEW.create_time); www.2cto.com
ELSIF ( NEW.create_time >= DATE '2012-03-01' AND
NEW.create_time < DATE '2012-04-01' ) THEN
INSERT INTO test.parent_table_2012_03 VALUES (NEW.id,NEW.name,NEW.create_time);
ELSIF ( NEW.create_time >= DATE '2012-04-01' AND
NEW.create_time < DATE '2012-05-01' ) THEN
INSERT INTO test.parent_table_2012_04 VALUES (NEW.id,NEW.name,NEW.create_time);
ELSIF ( NEW.create_time >= DATE '2012-05-01' AND
NEW.create_time < DATE '2012-06-01' ) THEN
INSERT INTO test.parent_table_2012_05 VALUES (NEW.id,NEW.name,NEW.create_time);
ELSIF ( NEW.create_time >= DATE '2012-06-01' AND
NEW.create_time < DATE '2012-07-01' ) THEN
INSERT INTO test.parent_table_2012_06 VALUES (NEW.id,NEW.name,NEW.create_time);
ELSIF ( NEW.create_time >= DATE '2012-07-01' AND
NEW.create_time < DATE '2012-08-01' ) THEN
INSERT INTO test.parent_table_2012_07 VALUES (NEW.id,NEW.name,NEW.create_time);
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>