如何在MySQL中查找列是否为auto_increment?
要查找列在MySQL中是否为auto_increment,可以使用以下语法-
select COLUMN_NAME from information_schema.columns whereTABLE_SCHEMA='yourDatabaseName' and TABLE_NAME='yourTableName' and EXTRA
like '%auto_increment%';
让我们首先创建一个表。在这里,ClientId设置为AUTO_INCREMENT-
mysql> create table autoIncrementTableDemo-> (
-> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> ClientName varchar(20),
-> ClientAge int,
-> ClientAddress varchar(100),
-> ClientCountryName varchar(100)
-> );
现在,让我们查找是否有任何列是auto_increment-
mysql> select COLUMN_NAME from information_schema.columns whereTABLE_SCHEMA='test' and TABLE_NAME='autoIncrementTableDemo' and EXTRA like
'%auto_increment%';
以下是给出列即auto_increment的输出-
+-------------+| COLUMN_NAME |
+-------------+
| ClientId |
+-------------+
1 row in set (0.00 sec)
以上是 如何在MySQL中查找列是否为auto_increment? 的全部内容, 来源链接: utcz.com/z/321823.html