Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- show create table rental;
- +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | Table | Create Table |
- +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | rental | CREATE TABLE `rental` (
- `driverid` int(11) NOT NULL DEFAULT '0',
- `carid` int(11) NOT NULL DEFAULT '0',
- `sdate` date NOT NULL DEFAULT '0000-00-00',
- `edate` date DEFAULT NULL,
- `rdate` date DEFAULT NULL,
- `cost` int(11) DEFAULT NULL,
- PRIMARY KEY (`driverid`,`carid`,`sdate`),
- KEY `fk_1_cust` (`carid`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
- +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- 1 row in set (0.00 sec)
- mysql> alter table rental add constraint fk_2_cust foreign key (driverid) references driverid;
- Query OK, 7 rows affected (0.15 sec)
- Records: 7 Duplicates: 0 Warnings: 0
- mysql> show create table rental;
- +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | Table | Create Table |
- +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | rental | CREATE TABLE `rental` (
- `driverid` int(11) NOT NULL DEFAULT '0',
- `carid` int(11) NOT NULL DEFAULT '0',
- `sdate` date NOT NULL DEFAULT '0000-00-00',
- `edate` date DEFAULT NULL,
- `rdate` date DEFAULT NULL,
- `cost` int(11) DEFAULT NULL,
- PRIMARY KEY (`driverid`,`carid`,`sdate`),
- KEY `fk_1_cust` (`carid`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
- +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- 1 row in set (0.00 sec)
Add Comment
Please, Sign In to add comment