Add 'CHECK( length(fieldname) > 0 )' to a field

Поиск
Список
Период
Сортировка
Искать

Add 'CHECK( length(fieldname) > 0 )' to a field

От:
"Daniel Seichter" <dseichter@radiomatic.com>
Дата:
Hello,

I have to let postgreSQL check the length of some fields in a database.
So I want to add the SQL Code "CHECK( length(fieldname) > 0 )" to some
fields so that the check will be executed during INSERT statement.
With the properties dialog I can't add the CHECK statement, so maybe it
isn't possible or I have to take a look to something. But to what?

Thank you in advance

Daniel Seichter

Re: Add 'CHECK( length(fieldname) > 0 )' to a field

От:
"Dave Page" <dpage@vale-housing.co.uk>
Дата:
 

> -----Original Message-----
> From: pgadmin-support-owner@postgresql.org 
> [mailto:pgadmin-support-owner@postgresql.org] On Behalf Of 
> Daniel Seichter
> Sent: 21 June 2005 14:58
> To: pgadmin-support@postgresql.org
> Subject: [pgadmin-support] Add 'CHECK( length(fieldname) > 0 
> )' to a field
> 
> Hello,
> 
> I have to let postgreSQL check the length of some fields in a 
> database.
> So I want to add the SQL Code "CHECK( length(fieldname) > 0 )" to some
> fields so that the check will be executed during INSERT statement.
> With the properties dialog I can't add the CHECK statement, 
> so maybe it
> isn't possible or I have to take a look to something. But to what?
> 
> Thank you in advance

Hi,

You can add a new table constraint (to check one or more columns) by
right-clicking the Constraints node under the table and selecting New
Object -> New Check Constraint. I don't think any of us ever saw much
value in allowing constraints directly on individual columns as well -
it would just over-complicate the GUI for no real gain.

Regards, Dave

FAQ