A new form to create the following
The CREATE TABLE Persons_Form
(
Id_P int the NOT NULL,
The LastName varchar (255) NOT NULL,
FirstName varchar (255),
Address varchar (255),
City varchar (255)
)
Then there are two kinds of circumstances, the first is a I edited the content of the form and edit content below
Then add conditions set statement
The ALTER TABLE Persons_Form ADD CONSTRAINT chk_Id_city CHECK (City! )
='sh'This time will be an error
The second case it is wrong to form content under the condition of edit (that is, the City options do not fill in the 'sh') added directly on the above a set statement, this time can be normal add
Then here are a few questions, according to my own perception, the add conditions set before most of the form data should be has been around for a large amount of data, if the existing data and check limit conflicts exist in the data will not be able to add new qualified, that should be how to add a new qualification, rearrange again if the original data to meet the qualification is workload is too heavy, I do not know whether my understanding biased
Another problem is I found through the ALTER TABLE Persons_Form ADD CHECK (City!='sh) approach can also add qualification, but if remove the limit with the ALTER TABLE Persons_Form DROP CHECK (City! )='sh' complains, and online query is DROP CHECK chk_Person way, that the chk_Person here is correspond to what
CodePudding user response:
Question 1:Put a violation of the value of the constraint condition of all the lines, to empty=', redo constraints, not line?
Question 2:
Opening and closing constraints:
//disable
The SET FOREIGN_KEY_CHECKS=0;
//enable
The SET FOREIGN_KEY_CHECKS=1;
//check the value of the current FOREIGN_KEY_CHECKS can use the following command
SELECT @ @ FOREIGN_KEY_CHECKS;