Re: Adding custom constraints on a postgres database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"David G. Johnston" <david.g.johnston@xxxxxxxxx> writes:
> On Thu, Feb 29, 2024, 11:10 Debraj Manna <subharaj.manna@xxxxxxxxx> wrote:
>> Can someone let me know if there is a way I can add some custom
>> rules/constraints on a Postgres database?
>> 
>> For example, all tables in a database should have a primary key specified.
>> If someone is trying to violate the rules specified then the SQL command
>> should fail.

> https://www.postgresql.org/docs/current/event-trigger-definition.html

When/where are you expecting to enforce this?  If you prohibit the
common pattern of CREATE TABLE followed sometime later by ALTER TABLE
ADD PRIMARY KEY, you will soon regret that.

I think you might be better served by writing a lint-like thing
that can be run periodically to look through the system catalogs
for policy violations.  Rejecting SQL commands on-the-fly will be
expensive, as well as painful to work with.

			regards, tom lane





[Index of Archives]     [Postgresql Home]     [Postgresql General]     [Postgresql Performance]     [Postgresql PHP]     [Postgresql Jobs]     [PHP Users]     [PHP Databases]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Forum]

  Powered by Linux