update view
От | Brian Haney |
---|---|
Тема | update view |
Дата | |
Msg-id | 000401bf38af$c04bab40$8101a8c0@specter.fresno.cybernaut.com обсуждение исходный текст |
Список | pgsql-general |
I'm trying to update a table through a view and have read up on what constitutes an 'updatable' view. I created a simple test case and cannot get it to update the table through the view. In the transcript below, notice that when I update the view, I get 'UPDATE 0' with no error message or other complaints. What am I missing? Does PostgreSQL not support updating through views? -- Brian Haney brian@cybernaut.com ============================ BEGIN SAMPLE ======================== $ psql -f /tmp/viewtest test2 create table peanuts ( name text, age int4, height int4, weight int4); CREATE insert into peanuts values ('Charlie Brown', 50, 24, 75); INSERT 21228 1 insert into peanuts values ('Snoopy', 21, 18, 25); INSERT 21229 1 insert into peanuts values ('Lucy van Pelt', 50, 27, 65); INSERT 21230 1 insert into peanuts values ('Linus van Pelt', 50, 24, 75); INSERT 21231 1 select * from peanuts; name |age|height|weight --------------+---+------+------ Charlie Brown | 50| 24| 75 Snoopy | 21| 18| 25 Lucy van Pelt | 50| 27| 65 Linus van Pelt| 50| 24| 75 (4 rows) create view dogs as select * from peanuts where name = 'Snoopy'; CREATE select * from dogs; name |age|height|weight ------+---+------+------ Snoopy| 21| 18| 25 (1 row) update dogs set age = 145; UPDATE 0 select * from dogs; name |age|height|weight ------+---+------+------ Snoopy| 21| 18| 25 (1 row) EOF $
В списке pgsql-general по дате отправления: