Category Archives: Database

Database optimisation tips and techniques

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 »

Create AutoIncrement column/field in Apache Derby

By | July 6, 2009

While creating a table a particular column / field can be made autoincrement as : CREATE TABLE students ( id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), name VARCHAR(24) NOT NULL, address VARCHAR(1024), CONSTRAINT primary_key PRIMARY KEY (id) ) ; The value of an autoincrement column increments automatically with… Read More »