Can I use VARCHAR as the PRIMARY KEY?

前端 未结 4 874
清酒与你
清酒与你 2020-12-01 07:13

I have a table for storing coupons/discounts, and I want to use the coupon_code column as the primary key, which is a VARCHAR.

My rationale is that, eac

4条回答
  •  温柔的废话
    2020-12-01 07:46

    It is ok for sure. With just few hundred of entries, it will be fast.

    You can add an unique id as as primary key (int autoincrement) ans set your coupon_code as unique. So if you need to do request in other tables it's better to use int than varchar

提交回复
热议问题