How to add and delete unique indexes for fields in MySQL

How to add and delete unique indexes for fields in MySQL

1. Add PRIMARY KEY (primary key index)

mysql>ALTER TABLE `table_name` ADD PRIMARY KEY (`column`)

2. Add UNIQUE (unique index)

mysql>ALTER TABLE `table_name` ADD UNIQUE ( `column` )

3. Add INDEX (normal index)

mysql>ALTER TABLE `table_name` ADD INDEX index_name (`column`)

4. Add FULLTEXT (full-text index)

mysql>ALTER TABLE `table_name` ADD FULLTEXT (`column`)

5. Add multi-column indexes

mysql>ALTER TABLE `table_name` ADD INDEX index_name ( `column1`, `column2`, `column3` )

The above method of adding and deleting unique indexes (unique) for fields in MySQL is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Solve the problem of SQL Server saving object string conversion into uniqueidentifier failure
  • The use of mysql unique key in query and related issues
  • Explanation of MySQL index types Normal, Unique and Full Text
  • MySQL uses UNIQUE to implement non-duplicate data insertion
  • How to solve the problem of inserting duplicate values ​​into unique columns in Mysql
  • SQL statement to convert uniqueidentifier into varchar data type
  • Detailed explanation of the principles and applications of Unique SQL

<<:  Get a list of your top 10 most frequently used terminal commands in Linux

>>:  Pros and Cons of Vite and Vue CLI

Recommend

The concept and characteristics of MySQL custom variables

A MySQL custom value is a temporary container for...

Teach you how to subcontract uniapp and mini-programs (pictures and text)

Table of contents 1. Mini Program Subcontracting ...

Reasons and solutions for prompting to save action after uploading files in form

The json data must be returned in html format That...

Several methods to clear floating (recommended)

1. Add an empty element of the same type, and the...

CSS realizes the mask effect when the mouse moves to the image

1. Put the mask layer HTML code and the picture i...

Sample code for deploying Spring-boot project with Docker

1. Basic Spring-boot Quick Start 1.1 Quick start ...

Hadoop 3.1.1 Fully Distributed Installation Guide under CentOS 6.8 (Recommended)

Foregoing: This document is based on the assumpti...

Can MySQL's repeatable read level solve phantom reads?

introduction When I was learning more about datab...

Detailed explanation of how to use element-plus in Vue3

Table of contents 1. Installation 2. Import in ma...

WeChat applet implements text scrolling

This article example shares the specific code for...

Ten Experiences in Presenting Chinese Web Content

<br /> Focusing on the three aspects of text...

Summary of solutions for MySQL not supporting group by

I downloaded and installed the latest version of ...

Do designers need to learn to code?

Often, after a web design is completed, the desig...