×

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 Triggers

MySQL trigger is a function of the stored procedure to respond to the system program. This function responds and runs any data table event automatically. You can use it for...

5 minutes read.

MySQL EQUI JOIN

An equijoin is an operation that combines multiple tables based on equality or matching column values in the associated tables. This operation links more than two tables based on a...

5 minutes read.

MySQL MAX function

The MAX function is a type of aggregation function that determines the maximum value of the table data. This function works on numerical data type values. If the table displays...

4 minutes read.

MySQL PI() function

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

2 minutes read.

MySQL MIN function

The MIN() function determines the minimum or lowest value of the data set. This function works on numerical data type values. If the table displays zero value, then the row...

4 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 ISNULL function

This function is used to check the null value in table data. It returns the result in a Boolean form. If table data is null, then the output becomes 1....

2 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 LENGTH() Function

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

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

The natural join combines multiple tables using a column with the same name and data type. This operation combines a row of the two tables using common columns. This join...

4 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 INNER JOIN

MySQL inner join connects two tables by using their common columns. It is the basic join of the MySQL system. It is used to returns only those results from the...

4 minutes read.

MySQL: Entity-Relationship Model

Entity-Relationship Model Entity-Relationship model or E R model is used to create a relationship between different attributes or entities. It describes the structure of the database with the help of the...

5 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 FORMAT() function

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

2 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 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 GREATEST function

This statement displays the greatest values of the table. The GREATEST function returns a null value when the table contains a null value. The GREATEST function needs a minimum of...

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