MySQL:如何在 phpMyAdmin 上设置主键?

2022-01-05 00:00:00 mysql phpmyadmin

帮助!第一次使用 phpMyAdmin.我想设置为主键的列是phpMyAdmin中的TEXT,提示错误,不能设置主键!而且我不想将其更改为 INT.我该如何解决这个问题?百万感谢!

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 don't want to change it to INT. How can I solve this? Million thanks!

附注.我还没有在这个表上输入任何值或关联任何其他表.

PS. I haven't input any values or relate any other tables on this table yet.

推荐答案

您可以在文本列上设置主键.在 phpMyAdmin 中,显示表的结构,单击索引,然后要求在某一列上创建索引.然后选择 PRIMARY,选择您的 TEXT 列,但您必须输入足够大的长度以使其唯一.

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.

相关文章