×

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 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 Descending Index

Descending Index It is a type of index that stores key values in descending order. This query improves the performance of an index query. MySQL system displays the index as per...

3 minutes read.

MySQL RTRIM() function

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

2 minutes read.

MySQL Drop Index

Sometimes we have an index that is not required in data operations. In that case, we can use this statement to remove an existing index from the table. We can...

4 minutes read.

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 UPDATE JOIN

The UPDATE JOIN is a MySQL statement used to perform cross-table updates that means we can update one table using another table with the JOIN clause condition. The "update join"...

5 minutes read.

MySQL CONCAT() function

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

3 minutes read.

MySQL CROSS JOIN

MySQL CROSS JOIN combines all possibilities of the two or more tables and returns the result that contains every row from all contributing tables. It links several columns from the...

4 minutes read.

MySQL EXPORT_SET() function

In this context, we will learn how we can use the MySQL EXPORT_SET() function with proper syntax and good examples. Introduction of MySQL EXPORT_SET() function This function returns a string and shows...

3 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 logical conditions

MySQL logical conditions Introduction MySQL handles data with clauses, operators, and conditions. The logical condition is used to compare information and returns the required output. This condition applies logic to MySQL expressions...

7 minutes read.

MySQL FIELD() function

In this context, we will learn how we can use the MySQL FIELD() function with proper syntax and good examples. Introduction of MySQL FIELD() function The index position of a mentioned value...

3 minutes read.

MySQL INSTR() Function

In this context, we will learn how we can use the MySQL INSTR() function with proper syntax and good examples. Introduction of MySQL INSTR() function This function in MySQL returns the location...

4 minutes read.

MySQL Join

The relational database system needs to interconnect multiple tables with each other. MySQL is a popular and easy data management system to connect multiple tables. The foreign key is used...

5 minutes read.

MySQL Constraints

MySQL Constraints Introduction The constraints help to restrict what values should be stored in a table. The constraints provide limitations of the columns or data. This function helps to insert data in...

20 minutes read.

MySQL Tutorial

In this tutorial, you will get information about the MySQL management system. This tutorial will cover the basic and advanced level MySQL concepts with examples that will help you become...

5 minutes read.

MySQL RADIANS() function

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

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 CEIL() function

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

3 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.