Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql modify foreign key

-- 2 Step process
ALTER TABLE tbl_name_1 DROP FOREIGN KEY fk_name;
ALTER TABLE tbl_name_1 ADD FOREIGN KEY fk_name(fk_col)
            REFERENCES tbl_name_2(pk_name) ON DELETE RESTRICT;


-- Use to find the name of the FOREIGN KEY 
SHOW CREATE TABLE tbl_name;
Comment

mysql alter add foreign key

ALTER TABLE ordenes ADD ticket VARCHAR(50) NOT NULL;
ALTER TABLE ordenes ADD CONSTRAINT fk_ticket FOREIGN KEY (ticket) REFERENCES tickets(ticket);
// I'm Horrible Hyena
Comment

mysql alter add foreign key

ALTER TABLE ordenes ADD ticket VARCHAR(50) NOT NULL;
ALTER TABLE ordenes ADD CONSTRAINT fk_ticket FOREIGN KEY (ticket) REFERENCES tickets(ticket);
Comment

update foreign key value in mysql

SET foreign_key_checks = 0;
UPDATE languages SET id='xyz' WHERE id='abc';
UPDATE categories_languages SET language_id='xyz' WHERE language_id='abc';
SET foreign_key_checks = 1;
Comment

PREVIOUS NEXT
Code Example
Sql :: create new table plsql 
Sql :: get year from date postgres 
Sql :: created at and updated at in mysql 
Sql :: postgresql print sessions using the database 
Sql :: how to export db from mysql 
Sql :: crontab every month 
Sql :: oracle check table lock 
Sql :: t-sql remove all non-alphanumeric characters from a string 
Sql :: set database timezone mysql 
Sql :: mariadb alter user host 
Sql :: [2021-10-05T13:43:48.961Z] error Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client 
Sql :: how to get last row of table in sql 
Sql :: sql padd let with zeros 
Sql :: mysql count words 
Sql :: postgresql change column to not null 
Sql :: postgresql alter column nullable 
Sql :: xampp mysql database not starting 
Sql :: oracle reset sequence 
Sql :: sql find missing values between two tables 
Sql :: oracle user tables 
Sql :: sql reset auto increment 
Sql :: sql copy table structure 
Sql :: mysql bidirectional composite primary key 
Sql :: postgres check timezone 
Sql :: how to create a variable in mysql 
Sql :: mysql month name extract 
Sql :: oracle export view ddl 
Sql :: mysql modify default value 
Sql :: remove spaces sql server 
Sql :: show all users in mysql 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =