Guest User

Untitled

a guest
Jan 13th, 2018
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. show create table rental;
  2. +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  3. | Table | Create Table |
  4. +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  5. | rental | CREATE TABLE `rental` (
  6. `driverid` int(11) NOT NULL DEFAULT '0',
  7. `carid` int(11) NOT NULL DEFAULT '0',
  8. `sdate` date NOT NULL DEFAULT '0000-00-00',
  9. `edate` date DEFAULT NULL,
  10. `rdate` date DEFAULT NULL,
  11. `cost` int(11) DEFAULT NULL,
  12. PRIMARY KEY (`driverid`,`carid`,`sdate`),
  13. KEY `fk_1_cust` (`carid`)
  14. ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
  15. +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. 1 row in set (0.00 sec)
  17.  
  18. mysql> alter table rental add constraint fk_2_cust foreign key (driverid) references driverid;
  19. Query OK, 7 rows affected (0.15 sec)
  20. Records: 7 Duplicates: 0 Warnings: 0
  21.  
  22. mysql> show create table rental;
  23. +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | Table | Create Table |
  25. +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | rental | CREATE TABLE `rental` (
  27. `driverid` int(11) NOT NULL DEFAULT '0',
  28. `carid` int(11) NOT NULL DEFAULT '0',
  29. `sdate` date NOT NULL DEFAULT '0000-00-00',
  30. `edate` date DEFAULT NULL,
  31. `rdate` date DEFAULT NULL,
  32. `cost` int(11) DEFAULT NULL,
  33. PRIMARY KEY (`driverid`,`carid`,`sdate`),
  34. KEY `fk_1_cust` (`carid`)
  35. ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
  36. +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. 1 row in set (0.00 sec)
Add Comment
Please, Sign In to add comment