APD1993 Posted March 19, 2012 Share Posted March 19, 2012 Hi, I want to be able to add a primary key to a table through altering the table. At the moment, I am using coding such as: USE test3; ALTER table users ->ADD primary key (uname); But I get told: No database selected Does anyone know how to fix this? Any help is appreciated Link to comment https://forums.phpfreaks.com/topic/259254-how-to-alter-a-table-to-include-a-primary-key/ Share on other sites More sharing options...
aminkorea Posted March 21, 2012 Share Posted March 21, 2012 if you have phpmyadmin you can add a primary key very easily. If not try try ALTER TABLE table_name ADD PRIMARY KEY (column_name) In your case, ALTER table users ADD primary key (uname) should work. Link to comment https://forums.phpfreaks.com/topic/259254-how-to-alter-a-table-to-include-a-primary-key/#findComment-1329734 Share on other sites More sharing options...
The Little Guy Posted March 24, 2012 Share Posted March 24, 2012 OR: ALTER table test3.users ADD primary key (uname); Link to comment https://forums.phpfreaks.com/topic/259254-how-to-alter-a-table-to-include-a-primary-key/#findComment-1330769 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.