database logic
brief :
ALTER TABLE A
ADD CONSTRAINT id
PRIMARY KEY (id)
ALTER TABLE B
ADD COLUMN a_id VARCHAR
//add fkey in B as additional cols
ALTER TABLE B ADD COLUMN a_id int
//now create the fkey ref to agent table on address table
alter table B ADD Foreign key(a_id) references A(id);
//To obtain the generated constraint name of a table
SHOW CREATE TABLE B;
//to disable fkey checks.
ALTER TABLE A
ADD CONSTRAINT id
PRIMARY KEY (id)
ALTER TABLE B
ADD COLUMN a_id VARCHAR
//add fkey in B as additional cols
ALTER TABLE B ADD COLUMN a_id int
//now create the fkey ref to agent table on address table
alter table B ADD Foreign key(a_id) references A(id);
//To obtain the generated constraint name of a table
SHOW CREATE TABLE B;
ALTER TABLE B DROP FOREIGN KEY b_ibfk_1;
//to disable fkey checks.
SET foreign_key_checks = 0/1;
|
Comments
Post a Comment