Oracle Discussion Forums
Welcome, Guest. Please login or register.
September 07, 2010
Home Help Search Login Register
News:


+  WebForums - OraclePassport
|-+  IT Programming - UNIX, Java, MySQL, Toad
| |-+  MySQL Discussion Board
| | |-+  On Delete cascade & on update cascade in Mysql / Create index on table
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Send this topic Print
Author Topic: On Delete cascade & on update cascade in Mysql / Create index on table  (Read 366 times)
kushi
Professional
****

Appreciate? +7/-0
Offline Offline

Posts: 140

« on: May 05, 2009 »

CASCADE: Delete or update the row from the parent table and automatically delete or update the matching
rows in the child table. Both ON DELETE CASCADE and ON UPDATE CASCADE  are supported

Mysql>CREATE TABLE Employee
(
  EMPNO     Int(2)                           NOT NULL,
  ENAME     VARCHAR(10),
  JOB       VARCHAR(9),
  MGR       Int(4),
  HIREDATE  DATE,
  SAL       Int(10),
  DEPTNO    Int(2),
  FOREIGN KEY (DEPTNO) REFERENCES DEPT(DEPTNO) ON DELETE CASCADE ON UPDATE CASCADE
);


Mysql>CREATE TABLE DEPT
(
  DEPTNO  INT(2),
  DNAME   VARCHAR(14) ,
  LOC     VARCHAR(13),
  PRIMARY KEY(DEPTNO)
);


Creating Index on a Table.


mysql>CREATE TABLE myTable
     (
        DEPTNO  INT(2),
        DNAME   VARCHAR(14) ,
        LOC     VARCHAR(13),
        PRIMARY KEY(DEPTNO)
        INDEX (DEPTNO)
     );
Report to moderator   Logged

Kushi
Pages: [1] Go Up Send this topic Print 
« previous next »
 
Share this topic...
In a forum
(BBCode)
In a site/blog
(HTML)



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 2.0 RC1.2 | SMF © 2006–2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.766 seconds with 18 queries.