Unable to delete a column which is a primary key[unsolved]
Posted: Sun Jan 15, 2006 8:12 am
1. You can see the error coming up when I try to delete the column which is a primary key.
2. I am not able to add foreign key after creating table
Code: Select all
mysql> describe student_tbl;
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| id | int(11) | | PRI | NULL | auto_increment |
| name | varchar(35) | YES | | NULL | |
+-------+-------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
mysql> alter table
-> student_tbl
-> drop column
-> id;
ERROR 1025 (HY000): Error on rename of '.\test\#sql-68c_1fd' to '.\test\student_tbl' (err
no: 150)Code: Select all
mysql> describe studentscores_tbl;
+-----------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------------+------+-----+---------+----------------+
| id | int(11) | | PRI | NULL | auto_increment |
| studentid | int(11) | | MUL | 0 | |
| subjectid | int(10) unsigned | | | 0 | |
+-----------+------------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
mysql> describe subject_tbl;
+-------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------------+------+-----+---------+----------------+
| id | tinyint(3) unsigned | | PRI | NULL | auto_increment |
| name | varchar(25) | YES | | NULL | |
+-------+---------------------+------+-----+---------+----------------+
2 rows in set (0.02 sec)
mysql> alter table
-> studentscores_tbl
-> add
-> foreign key (subjectid) references subject_tbl(id);
ERROR 1005 (HY000): Can't create table '.\test\#sql-68c_1fe.frm' (errno: 150)