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 Quote 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. Quote 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); Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.