Home > database >  SQL column constraint problems
SQL column constraint problems

Time:10-31

Below the primary key of the employee table in the working status of the primary key of the former two tables for the department department, so gonghaowu constraint conditions of how to write?? Hope leaders can answer

CodePudding user response:

CodePudding user response:

The pictures looked at you, help you make is,
Staff table should increase a field: department, to match the regular table design principle,
Added the department number field, the working field constraint is simple:

 - 1. Increase the number of the department 
The ALTER TABLE ygb ADD BMH NCHAR (2)
GO
- 2. Increase the check constraint
The ALTER TABLE ygb ADD CONSTRAINT CK_ygb_gh CHECK (LEFT (gh, 2)=BMH)

CodePudding user response:

refer to the second floor of gypsy song response:
the pictures looked at you, help you make is,
Staff table should increase a field: department, to match the regular table design principle,
Added the department number field, the working field constraint is simple:

 - 1. Increase the number of the department 
The ALTER TABLE ygb ADD BMH NCHAR (2)
GO
- 2. Increase the check constraint
The ALTER TABLE ygb ADD CONSTRAINT CK_ygb_gh CHECK (LEFT (gh, 2)=BMH)
originally a division to increase the number of
Now understand, thank you for your bosses
  • Related