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

js to implement web calculator

How to make a simple web calculator using HTML, C...

How to use the HTML form attributes readonly and disabled

1. readonly read-only attribute, so you can get th...

Introduction to ufw firewall in Linux

Let's take a look at ufw (Uncomplicated Firew...

Detailed Example of JavaScript Array Methods

Table of contents Introduction Creating an Array ...

MySQL uses custom sequences to implement row_number functions (detailed steps)

After reading some articles, I finally figured ou...

Web Design Tutorial (2): On Imitation and Plagiarism

<br />In the previous article, I introduced ...

Simple usage example of vue recursive component

Preface I believe many students are already famil...

The homepage design best reflects the level of the web designer

In the many projects I have worked on, there is b...

Practice of dynamically creating dialog according to file name in vue+el-element

Table of contents background accomplish 1. Encaps...

Vue Page Stack Manager Details

Table of contents 2. Tried methods 2.1 keep-alive...

js implements a simple countdown

This article example shares the specific code of ...

How to reset your Linux password if lost

1. The startup menu is to move the cursor to the ...

Mac node deletion and reinstallation case study

Mac node delete and reinstall delete node -v sudo...

How to configure https for nginx in docker

Websites without https support will gradually be ...

Why the CSS attribute value clear:right does not work in detail

Using the clear property to clear floats is a comm...