Home  >  Article  >  Database  >  How to delete the auto-incrementing primary key in mysql

How to delete the auto-incrementing primary key in mysql

王林
王林Original
2020-10-16 09:28:228101browse

How to delete the auto-increment primary key in mysql: First, you need to delete auto_increment; then execute the [alter table data table name drop primary key;] statement to delete the primary key.

How to delete the auto-incrementing primary key in mysql

Deleting the primary key in MySQL requires the following two steps

(Recommended tutorial: mysql video tutorial)

(1) If there is auto_increment, delete it first;

(2) Delete the primary key constraint primary key

alter table t9 modify id int(11); #这里用的modify,只改变数据类型,也可以用change,改变列名的同时输入新的数据类型。
alter table t9 drop primary key; #删除主键

Related recommendations: mysql tutorial

The above is the detailed content of How to delete the auto-incrementing primary key in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn