check-constraints

Check constraint to validate IP address field.

Hi everyone, I'm working on a project involving C# and a SQL Server 2008 database. In one of the tables, I have a field (nvarchar(15)) which will contain an IP address. I'd like to add a check constraint which will validate that the input value is actually an IP address. I wanted to use a regex to do that, but it seems that this featu...

Does MySQL support check constraint?

Does MySQL support check constraint? I am able to execute the following script in MySQL without error. ALTER TABLE EMP_DB_DESIGN_EXCEL ADD ( CONSTRAINT CHK_EMP_IS_ACTIVE CHECK (IS_ACTIVE IN ('Y','N'))); But it is not reflected if I query: SELECT * FROM information_schema.TABLE_CONSTRAINTS T where t.table_name='EMP_DB_DESIGN_EX...

How do I have a check constraint that refers to another table?

I have the following tables in a SQL Server 2008 db: tblItem, which has an ItemID field; tblGoodItem, which also has an ItemID field, and has a foreign key pointing to tblItem; tblBadItem, which also has an ItemID field, and also has a foreign key pointing to tblItem. An item cannot be both a good item and a bad item; it must either ...

Constraints in SQL Database

I need to have a table in T-SQL which will have the following structure KEY Various_Columns Flag 1 row 1 F 2 row_2 F 3 row_3 T 4 row_4 F Either no rows, or at most one row can have the Flag column with the value T. My developer claims...

Check for integrity constraint violation in SQL before deletion

My question is sort of similar to this one I want to check if a DELETE query will fail because of a constraint violation. I'd like to do this on database level because I think letting it fail and catching the error is ugly. Another option is "manually" checking for it using SELECT queries to see if there are constraints, but this is ra...