How to “Unhide” an Invisible Column in MySQL

If you’ve got a table with an invisible column in MySQL, but you no longer want the column to be invisible, you can use the ALTER TABLE statement to make it visible.

Invisible columns are columns that can’t be accessed by queries that use the asterisk wildcard (*) to select all columns (although they can be accessed by explicitly naming the invisible column in the SELECT list).

Example

Suppose we run the DESCRIBE statement against the following table:

DESCRIBE t1;

Result:

+-------+------+------+-----+---------+-----------+
| Field | Type | Null | Key | Default | Extra     |
+-------+------+------+-----+---------+-----------+
| c1    | int  | YES  |     | NULL    |           |
| c2    | int  | YES  |     | NULL    |           |
| c3    | int  | YES  |     | NULL    | INVISIBLE |
+-------+------+------+-----+---------+-----------+

This table is called t1, and it has an invisible column called c3. We know it’s an invisible column because it’s got INVISIBLE in the Extra column.

Anyway, let’s change it to a visible column:

ALTER TABLE t1 MODIFY COLUMN c3 int VISIBLE;

Result:

Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

That basically “un-hid” the invisible column and it is now visible.

Re-Check the Table

We can check this with the DESCRIBE statement again:

DESCRIBE t1;

Result:

+-------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-----+---------+-------+
| c1    | int  | YES  |     | NULL    |       |
| c2    | int  | YES  |     | NULL    |       |
| c3    | int  | YES  |     | NULL    |       |
+-------+------+------+-----+---------+-------+

We can see that INVISIBLE no longer appears in the Extra column. This means that it’s visible. VISIBLE is the default setting, and so visible columns don’t have any visibility information in the Extra column.