×

MySQL Invisible Index

Invisible Index

MySQL index decides an option to the availability of the index for the query optimizer. This index shows the visible and invisible options to displays the index column in the table. MySQL maintains the invisible indexes and keeps them updated when the data in the columns associated with the indexes changes.

MySQL management system provides a visible index by default. The invisible index supports to privacy and safety of the key columns.

Syntax

The basic syntax of the invisible index shows below.

 CREATE TABLE table_name(
 Column1data type NOT NULL PRIMARY KEY,
 Column2 data type VARCHAR (10) NOT NULL,
 INDEX (index name)INVISIBLE); 

The following points should be remembered while using this syntax:

  • The primary key column does not apply an invisible index.
  • The other column applies the invisible statement on the table.

The basic syntax of the invisible index shows below.

CREATE INDEX name ON table name (column1, column2, columnN) INVISIBLE;

The following points should be remembered while using this syntax:

  • Create index with the  required index name using MySQL query.
  • The "INVISIBLE" keyword requires for invisible index.

The syntax of the invisible index on the existing table shows below.

 ALTER TABLE name ALTER INDEX name INVISIBLE;
 The syntax of the visible index on the existing index shows below.
 ALTER TABLE name ALTER INDEX name VISIBLE; 

Examples of the Invisible index

1) Example: Create an invisible index by using a CREATE table command.

Execute the below query to create a new index with an invisible option. 

 mysql> create table index_table(
 roll_number INT NOT NULL PRIMARY KEY,
 name VARCHAR(10) NOT NULL,
 mark text NOT NULL,
 img blob NOT NULL,
 INDEX (name)INVISIBLE); 

OUTPUT

Execute the below query to show the index on the table.

mysql> show index from index_table;
Invisible Index

The above image shows an index of the table. The name column assigns for the invisible index.  Here, the visibility shows a "NO" value.

2) Example: Create an invisible index with an existing table.

Execute the below query to create a new index with an invisible option. 

mysql> CREATE INDEX mark ON index_table (mark (100)) INVISIBLE;

OUTPUT

Execute the below query to show the index on the table.

mysql> show index from index_table;
Invisible Index

The above image shows three rows of invisible indexes. It contains the key name, column name, index type, and visibility of the table. Here, the mark column visibility shows the "NO" value with prefix.

3) Example: Create an invisible index with an existing index.

Execute the below query to update the index with the invisible option.

mysql> ALTER TABLE index_table ALTER INDEX name INVISIBLE;

OUTPUT

Execute the below query to show the index on the table.

mysql> show index from index_table;

Invisible Index

The above image shows three rows of invisible indexes. The table shows the key name, column name, index type, visibility of the table. The name isassigned with NO value in the visible column.

4) Example: Create a visible index with the existing index.

Execute the below query to update the index with the invisible option.

mysql> ALTER TABLE index_table ALTER INDEX name VISIBLE;

OUTPUT

Execute the below query to show the index on the table.

mysql> show index from index_table;

Invisible Index

The above image shows three rows of invisible indexes. It contains the key name, column name, index type, and visibility of the table. Here, the name column is converted from an invisible to visible option.


Related Topics

MySQL REVERSE() function

In this context, we will learn how we can use the MySQL REVERSE() function with proper syntax and good examples. Introduction of MySQL REVERSE() function This function could be used to reverse...

2 minutes read.

MySQL LOG2() function

In this context, we will learn how we can use the MySQL LOG2() function to calculate the Logarithm of a specific number with base 2 with proper syntax and examples. Introduction...

2 minutes read.

MySQL ELT() function

In this context, we will learn how we can use the MySQL ELT() function with proper syntax and good examples. Introduction of MySQL ELT() function In the ELT function, the number field...

2 minutes read.

MySQL variable

The MySQL variable is essential for storing data in the table. The variable declares data with a specific name or label to avoid confusion. This data label is used in...

6 minutes read.

MySQL database queries

MySQL database queries Database queries help to create, use, show and, delete the database. A Database is a collection of several tables and data. The database uses SQL language to perform...

3 minutes read.

MySQL LN() function

In this context, we will learn how we can use the MySQL LN() function with proper syntax and good examples. Introduction of MySQL LN() function For evaluation of the natural logarithm of...

2 minutes read.

MySQL LOCATE() function

In this context, we will learn how we can use the MySQL LOCATE() function with proper syntax and good examples. Introduction of MySQL LOCATE() function LOCATE() function in MySQL is used for...

3 minutes read.

MySQL function

MySQL function is a piece of program to perform some specific task. Here we pass a parameter and then return a single value. MySQL function mainly supports string, numeric, conditional,...

9 minutes read.

MySQL Environmental Setup

The MySQL Environmental Setup MySQL is free, open-source, and cross-platform software, which can be downloaded from its official website. MySQL management system installs on Linux, macOS, and windows. MySQL requires a framework...

6 minutes read.

MySQL FLOOR() function

In this context, we will learn how we can use the MySQL FLOOR() function with proper syntaxes and examples. Introduction of MySQL Floor() function: FLOOR() function in MySQL is used to return...

3 minutes read.

MySQL HEX() function

In this context, we will learn how we can use the MySQL HEX() function with proper syntax and good examples. Introduction of MySQL HEX() function For returning an equivalent hexadecimal string value...

3 minutes read.

MySQL LOAD_FILE() function

In this context, we will learn how we can use the MySQL LOAD_FILE() function with proper syntax and good examples. Introduction of MySQL LOAD_FILE() function The LOAD_FILE() function in MySQL reads a...

3 minutes read.

MySQL Truncate() Function

In this context, we will learn how we can use the MYSQL TRUNCATE function to truncate a number to a mentioned number of decimal places. Syntax of MySQL Truncate Function A number...

2 minutes read.

MySQL Error 1046 - No Database Selected

What is MySQL? MySQL is a Relational Database Management System (RDBMS). SQL in MySQL is the abbreviation of "Structured Query Language", which Oracle developed it in 1995. It is one of...

1 minute read.

MySQL Subquery

The subquery is a MySQL query used to manage data operations. Mainly subquery helps to retrieve data with the necessary condition. It creates a nested query with two different queries....

5 minutes read.

MySQL SUM function

The SUM() function displays the total addition of the table values. It supports the arithmetic operation of the column values. This function does not return a null value. Here, the...

5 minutes read.

MySQL String Function

The string function is used to maintain and operate string values. This function modifies the string data as per function. We can do the concatenation, conversion, removal and replacing the...

4 minutes read.

MySQL DATE_ADD() function

In this context, we will learn how we can use the MySQL DATE_ADD() function with proper syntax and good examples. Introduction of MySQL DATE_ADD() function In MySQL, the DATE_ADD() function is used...

3 minutes read.

MySQL DAY() function

In this context, we will learn how we can use the MySQL DAY() function with proper syntax and good examples. Introduction of MySQL DAY() function This function in MySQL is used to...

2 minutes read.

MySQL INSERT() Function

In this context, we will learn how we can use the MySQL INSERT() function with proper syntax and good examples. Introduction of MySQL INSERT() function Basically, in MySQL, the INSERT function is...

2 minutes read.