mysql> desc student;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| name | varchar(20) | YES | | NULL | |
| class | varchar(10) | YES | | NULL | |
| rollno | int(11) | YES | | NULL | |
| marks | int(11) | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
4 rows in set (0.01 sec)
mysql> alter table student add primary key (rollno);
Query OK, 2 rows affected (0.41 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> create table act(acode varchar(10),rollno int(11),foreign key(rollno) references
student(rollno));
Query OK, 0 rows affected (0.16 sec)
sql> desc act
-> ;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| acode | varchar(10) | YES | | NULL | |
| rollno | int(11) | YES | MUL | NULL | |
+--------+-------------+------+-----+---------+-------+
2 rows in set (0.01 sec)