MySQL: How to set the Primary Key on phpMyAdmin?

前端 未结 4 1271
迷失自我
迷失自我 2021-02-07 04:50

Help! First time using phpMyAdmin. The column that I intend to set as a primary key is of TEXT in phpMyAdmin, it gave me an error message, the primary key can\'t be set! And I d

相关标签:
4条回答
  • 2021-02-07 05:12

    You can view the INDEXES column below where you find a default PRIMARY KEY is set. If it is not set or you want to set any other variable as a PRIMARY KEY then , there is a dialog box below to create an index which asks for a column number ,either way you can create a new one or edit an existing one.The existing one shows up a edit button whee you can go and edit it and you're done save it and you are ready to go

    0 讨论(0)
  • 2021-02-07 05:13

    MySQL can index the first x characters of a column,but a TEXT type is of variable length so mysql cant assure the uniqueness of the column.If you still want text column,use VARCHAR.

    0 讨论(0)
  • 2021-02-07 05:23

    You can't set the field having data-type "text". Only because of that thing you are getting this error. Try to change the data-type with int

    0 讨论(0)
  • 2021-02-07 05:31

    You can set a primary key on a text column. In phpMyAdmin, display the Structure of your table, click on Indexes, then ask to create the index on one column. Then choose PRIMARY, pick your TEXT column, but you have to put a length big enough so that its unique.

    0 讨论(0)
提交回复
热议问题