且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获取表的主键?

更新时间:2023-11-24 13:26:52

更好的方法是使用SHOW KEYS,因为您并非总是可以访问information_schema.以下作品:

A better way is to use SHOW KEYS since you don't always have access to information_schema. The following works:

SHOW KEYS FROM table WHERE Key_name = 'PRIMARY'

Column_name将包含主键的名称.

Column_name will contain the name of the primary key.