Skip to main content

Some useful commands

How to change the engine type of a table :
>alter table reportsTransfer engine= innodb ;

How to add foreign key to a table :

>ALTER TABLE tbl_name
    ADD [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name, ...)
REFERENCES tbl_name (index_col_name, ...)
[ON DELETE {RESTRICT | CASCADE | SET NULL | NO ACTION}]
[ON UPDATE {RESTRICT | CASCADE | SET NULL | NO ACTION}]

e.g
>alter table reportsTransfer add foreign key reportsId (reportsInsertedId ) references reportsInserted (id)


Note
> Before adding a foreign key to table make sure both the tables ( Reference table and table having foreign key ) engine type = InnoDb .
>InnoDB
does not check foreign key constraints on those foreign key or referenced key
values that contain a NULL column.
>Currently, triggers are not activated by cascaded foreign key actions.

Explain doesn't works with Delete and Update statement.

Comments

Popular posts from this blog

Backslash on mac

I had been struggling to type back slash ( \) character on mac japanese keyboard as they don't have it printed on the keyboard, and I was doing copy paste all the time from google when i needed to type it until recently a tip came to my rescue , shortcut to backslash on mac japanese keyboard. Alt + ¥  Hope it helps others. 

How to Enter Split View on MAC

Enter Split  View Hover your pointer over the full-screen button in the upper-left corner of a  window . Or click and hold the button. Choose ”Tile  Window  to Left of Screen” or ”Tile  Window  to Right of Screen” from the menu. ... Then click a  window  on the other side of the screen to begin using both  windows  side by side. Hover your pointer over the full-screen button in the upper-left corner of a  window . Or click and hold the button. Choose ”Tile  Window  to Left of Screen” or ”Tile  Window  to Right of Screen” from the menu. ... Then click a  window  on the other side of the screen to begin using both  windows  side by side.