Tag Archives: mysql

How to List foreign keys in Mysql

By | November 14, 2023

information_schema The following query will list out the foreign keys in mysql. It finds it out from the information_schema database. select concat(table_name, '.', column_name) as 'foreign key', concat(referenced_table_name, '.', referenced_column_name) as 'references' from information_schema.key_column_usage where referenced_table_name is not null; The output is a clean table listing out all foreign keys from all databases +———————–+————-+ |… Read More »

Create foreign key using Phpmyadmin

By | May 9, 2020

The innodb storage engine supports foreign keys in Mysql. To create foreign keys in phpmyadmin : 1. Convert both tables into innodb, if they are not already. 2. View the structure of the table which will have a foreign key. Make the referencing field an INDEX. 3. Now come back to structure view and click… Read More »

Backup mysql database with php and zip it

By | May 1, 2009

Many php applications prefer to backup the mysql database from within the application and save it as an archive. The mysqldump commandline utility can be used to perform this function of backing up a mysql database as sql file. The command would be like this : mysqldump –user=$username –password=$password –opt $db_name > $dir/backup.sql The above… Read More »