Re: add constraints to views
От | Andreas Fromm |
---|---|
Тема | Re: add constraints to views |
Дата | |
Msg-id | 3F6C5DF4.10006@physik.uni-erlangen.de обсуждение исходный текст |
Ответ на | Re: add constraints to views (Gaetano Mendola <mendola@bigfoot.com>) |
Ответы |
Re: add constraints to views
|
Список | pgsql-general |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Gaetano Mendola wrote: | Andreas Fromm wrote: | |> CREATE VIEW test_view ( |> ~ SELECT * FROM test_table WHERE tag |> ); |> |> Now I want ad a NOT NULL constraint to the view on field1. I tryed the |> following, but neither works. | | | what does mean add a null constrain to a view ? Do you mean | filter out the records with the field1 null ? | | CREATE OR REPLACE test_view AS | SELECT * | FROM test_table | WHERE field1 IS NOT NULL AND | tag; | No, I mean that the view behaves like a table with the same columns as table, but that restricts to records on wich tag is set. To insert a record to this "special" table it requires to have field1 set. In other words: A record of table is a record of view if tag is set. If tag is set, then field1 has also have to have a value. If tag is not set, it may have a value for field1, but will not show up in the view. Of course I could achive this be triggers, but I thought it could be possible to do via constraints on the view. Regards Andreas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) Comment: Using GnuPG with Debian - http://enigmail.mozdev.org iD8DBQE/bF30PkvkZVZzNY0RAqh8AJ0ZwagGrOhyuma/7gARKl1l35/wOACfVj9d xYvyd2Pet25drqcv4vBE5eg= =jXUQ -----END PGP SIGNATURE-----
В списке pgsql-general по дате отправления: