How to add Primary Key and Auto Increment on different fields of MySql

 Normal code generated by MySql:-

CREATE TABLE `categorymaster` (
  `CategoryID` int(11) NOT NULL AUTO_INCREMENT,
  `Category` varchar(200) DEFAULT NULL,
  `IsActiv` int(11) DEFAULT NULL,
  `ImagePath` varchar(200) DEFAULT NULL,
  `DisplayOrder` int(11) DEFAULT NULL,
  PRIMARY KEY (`Category`)

In the above data stucture I want to make the "Category" as Primary Key and "CategoryId" as Auto Increment.

But Table Wizard always give errors so, I decided to write my own Statement.

Following is the statement which will create perfect structure according to my requirement.

DROP TABLE `dbname`.`categorymaster`;
CREATE TABLE `categorymaster` (
  `CategoryId` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `Category` varchar(200) DEFAULT NULL,
  `IsActiv` int(11) DEFAULT NULL,
  `ImagePath` varchar(200) DEFAULT NULL,
  `DisplayOrder` int(11) DEFAULT NULL,
  UNIQUE KEY `CategoryId` (`CategoryId`),
   PRIMARY KEY (`Category`)


Thiago daLuz said...

Thanks for sharing this. We're hoping to get some of this implemented by next quarter. This'll make things much easier. Thiago | http://www.cvd.net.au/cvd-solutions.html

.Net training in Lucknow said...

useful post... Thanks for sharing.

Payoffers dotin said...

Earn from Ur Website or Blog thr PayOffers.in!


Nice to e-meet you. A very warm greetings from PayOffers Publisher Team.

I am Sanaya Publisher Development Manager @ PayOffers Publisher Team.

I would like to introduce you and invite you to our platform, PayOffers.in which is one of the fastest growing Indian Publisher Network.

If you're looking for an excellent way to convert your Website / Blog visitors into revenue-generating customers, join the PayOffers.in Publisher Network today!

Why to join in PayOffers.in Indian Publisher Network?

* Highest payout Indian Lead, Sale, CPA, CPS, CPI Offers.
* Only Publisher Network pays Weekly to Publishers.
* Weekly payments trough Direct Bank Deposit,Paypal.com & Checks.
* Referral payouts.
* Best chance to make extra money from your website.

Join PayOffers.in and earn extra money from your Website / Blog


If you have any questions in your mind please let us know and you can connect us on the mentioned email ID info@payoffers.in

I’m looking forward to helping you generate record-breaking profits!

Thanks for your time, hope to hear from you soon,
The team at PayOffers.in

ppc experts said...

Inbound Technical Support call | Call at: +91 981-142-0083 | inbound calls for tech support | tech support inbound calls A great online marketing company for tech support inbound calls, Inbound Technical Support call by osiel web

ServeLite solution said...

Hey I was doing some research on "Complete IT Solutions" when I came across here at this Awesome post.

Sarah Taylor said...

It is an informative blog. I hope you would share more writing for helping us. economical It solutions are the need of everyone now a day that’s why the business of running a software house in developing.

James Brown said...

This is such a great resource that you providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It is the old what goes around comes around routine.
SEO services pakistan

Web Development Company in India said...

Thank you so much for sharing. Well described. It helped a lot.

blogger said...

Thanks for sharing sql connection command. Yburis Infotech Pvt Ltd full IT solution provider company. For any help contact us.

Career Maker Infra said...

Nice blog..! I really loved reading through this article.Thanks for sharing.
Please do visit my website hope you'll like it:
Best real estate company in Lucknow
Best properties in Lucknow
Best plots in Lucknow
Fastest growing real estate company in Lucknow
Best Real estate company
Best development company in Lucknow

Adarsh Bagwani said...

Thanks for posting useful information.You have provided an nice article.
Please do visit my website hope you'll like it: Best nursery plants in Jaunpur
Best nursery services
Best Nursery plants
Best Bagwani services

Meal4U said...

I have read many of your post and this post is wonderful.... all of your post are just awesome
Please do visit my website hope you'll like it: Best tiffin service provider in Lucknow
Best Tiffin service in Lucknow
Best Tiffin Service
Best Homemade Food

Priya Singh said...

Thank you so much for sharing this article. if you want to get if you want to get any type of information about software or website then visit us.

Akhand Pratap Singh said...

Bigtown group is the best real estate comapny in lucknow
we provide luxirious homes and apartments in lucknow
for more info visit us: Bigtown Group

Ashish Singh said...

Nice Blog! Thanks for sharing.
Website Development Company in Lucknow