Set a filter on field type to fetch MySQL columns with type text?


To set a filter for type, you can use below syntax −

SELECT TABLE_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE DATA_TYPE = 'yourDataTypeName';

Let us implement the above syntax to show fields only with field type text −

mysql> SELECT
TABLE_NAME, COLUMN_NAME
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
DATA_TYPE = 'text';

This will produce the following output −

+---------------------------------------------+--------------------------------+
| TABLE_NAME                                  | COLUMN_NAME                    |
+---------------------------------------------+--------------------------------+
| COLUMNS                                     | COLUMN_DEFAULT                 |
| COLUMNS                                     | COLUMN_COMMENT                 |
| FILES                                       | FILE_NAME                      |
| PARTITIONS                                  | PARTITION_DESCRIPTION          |
| PARTITIONS                                  | PARTITION_COMMENT              |
| ROUTINES                                    | ROUTINE_COMMENT                |
| replication_group_member_stats              | LAST_CONFLICT_FREE_TRANSACTION |
| password_history                            | Password                       |
| component                                   | component_urn                  |
| innodb_buffer_stats_by_schema               | object_schema                  |
| innodb_buffer_stats_by_schema               | allocated                      |
| innodb_buffer_stats_by_schema               | data                           |
| x$innodb_buffer_stats_by_schema             | object_schema                  |
| innodb_buffer_stats_by_table                | object_schema                  |
| innodb_buffer_stats_by_table                | object_name                    |
| innodb_buffer_stats_by_table                | allocated                      |
| innodb_buffer_stats_by_table                | data                           |
| x$innodb_buffer_stats_by_table              | object_schema                  |
| x$innodb_buffer_stats_by_table              | object_name                    |
| x$schema_flattened_keys                     | index_columns                  |
| schema_redundant_indexes                    | redundant_index_columns        |
| schema_redundant_indexes                    | dominant_index_columns         |
| latest_file_io                              | latency                        |
| latest_file_io                              | requested                      |
| io_by_thread_by_latency                     | total_latency                  |
| io_by_thread_by_latency                     | min_latency                    |
| io_by_thread_by_latency                     | avg_latency                    |
| io_by_thread_by_latency                     | max_latency                    |
| io_global_by_file_by_bytes                  | total_read                     |
| io_global_by_file_by_bytes                  | avg_read                       |
| io_global_by_file_by_bytes                  | total_written                  |
| io_global_by_file_by_bytes                  | avg_write                      |
| io_global_by_file_by_bytes                  | total                          |
| io_global_by_file_by_latency                | total_latency                  |
| io_global_by_file_by_latency                | read_latency                   |
| io_global_by_file_by_latency                | write_latency                  |
| io_global_by_file_by_latency                | misc_latency                   |
| io_global_by_wait_by_bytes                  | total_latency                  |
| io_global_by_wait_by_bytes                  | min_latency                    |
| io_global_by_wait_by_bytes                  | avg_latency                    |
| io_global_by_wait_by_bytes                  | max_latency                    |
| io_global_by_wait_by_bytes                  | total_read                     |
| io_global_by_wait_by_bytes                  | avg_read                       |
| io_global_by_wait_by_bytes                  | total_written                  |
| io_global_by_wait_by_bytes                  | avg_written                    |
| io_global_by_wait_by_bytes                  | total_requested                |
| io_global_by_wait_by_latency                | total_latency                  |
| io_global_by_wait_by_latency                | avg_latency                    |
| io_global_by_wait_by_latency                | max_latency                    |
| io_global_by_wait_by_latency                | read_latency                   |
| io_global_by_wait_by_latency                | write_latency                  |
| io_global_by_wait_by_latency                | misc_latency                   |
| io_global_by_wait_by_latency                | total_read                     |
| io_global_by_wait_by_latency                | avg_read                       |
| io_global_by_wait_by_latency                | total_written                  |
| io_global_by_wait_by_latency                | avg_written                    |
| memory_by_user_by_current_bytes             | current_allocated              |
| memory_by_user_by_current_bytes             | current_avg_alloc              |
| memory_by_user_by_current_bytes             | current_max_alloc              |
| memory_by_user_by_current_bytes             | total_allocated                |
| memory_by_host_by_current_bytes             | current_allocated              |
| memory_by_host_by_current_bytes             | current_avg_alloc              |
| memory_by_host_by_current_bytes             | current_max_alloc              |
| memory_by_host_by_current_bytes             | total_allocated                |
| memory_by_thread_by_current_bytes           | current_allocated              |
| memory_by_thread_by_current_bytes           | current_avg_alloc              |
| memory_by_thread_by_current_bytes           | current_max_alloc              |
| memory_by_thread_by_current_bytes           | total_allocated                |
| memory_global_by_current_bytes              | current_alloc                  |
| memory_global_by_current_bytes              | current_avg_alloc              |
| memory_global_by_current_bytes              | high_alloc                     |
| memory_global_by_current_bytes              | high_avg_alloc                 |
| memory_global_total                         | total_allocated                |
| schema_index_statistics                     | select_latency                 |
| schema_index_statistics                     | insert_latency                 |
| schema_index_statistics                     | update_latency                 |
| schema_index_statistics                     | delete_latency                 |
| schema_table_statistics                     | total_latency                  |
| schema_table_statistics                     | fetch_latency                  |
| schema_table_statistics                     | insert_latency                 |
| schema_table_statistics                     | update_latency                 |
| schema_table_statistics                     | delete_latency                 |
| schema_table_statistics                     | io_read                        |
| schema_table_statistics                     | io_read_latency                |
| schema_table_statistics                     | io_write                       |
| schema_table_statistics                     | io_write_latency               |
| schema_table_statistics                     | io_misc_latency                |
| schema_table_statistics_with_buffer         | fetch_latency                  |
| schema_table_statistics_with_buffer         | insert_latency                 |
| schema_table_statistics_with_buffer         | update_latency                 |
| schema_table_statistics_with_buffer         | delete_latency                 |
| schema_table_statistics_with_buffer         | io_read                        |
| schema_table_statistics_with_buffer         | io_read_latency                |
| schema_table_statistics_with_buffer         | io_write                       |
| schema_table_statistics_with_buffer         | io_write_latency               |
| schema_table_statistics_with_buffer         | io_misc_latency                |
| schema_table_statistics_with_buffer         | innodb_buffer_allocated        |
| schema_table_statistics_with_buffer         | innodb_buffer_data             |
| schema_table_statistics_with_buffer         | innodb_buffer_free             |
| schema_tables_with_full_table_scans         | latency                        |
| schema_table_lock_waits                     | waiting_account                |
| schema_table_lock_waits                     | blocking_account               |
| x$schema_table_lock_waits                   | waiting_account                |
| x$schema_table_lock_waits                   | blocking_account               |
| statement_analysis                          | total_latency                  |
| statement_analysis                          | max_latency                    |
| statement_analysis                          | avg_latency                    |
| statement_analysis                          | lock_latency                   |
| statements_with_full_table_scans            | total_latency                  |
| statements_with_runtimes_in_95th_percentile | total_latency                  |
| statements_with_runtimes_in_95th_percentile | max_latency                    |
| statements_with_runtimes_in_95th_percentile | avg_latency                    |
| statements_with_sorting                     | total_latency                  |
| statements_with_temp_tables                 | total_latency                  |
| user_summary_by_file_io_type                | latency                        |
| user_summary_by_file_io_type                | max_latency                    |
| user_summary_by_file_io                     | io_latency                     |
| user_summary_by_statement_type              | total_latency                  |
| user_summary_by_statement_type              | max_latency                    |
| user_summary_by_statement_type              | lock_latency                   |
| user_summary_by_statement_latency           | total_latency                  |
| user_summary_by_statement_latency           | max_latency                    |
| user_summary_by_statement_latency           | lock_latency                   |
| user_summary_by_stages                      | total_latency                  |
| user_summary_by_stages                      | avg_latency                    |
| user_summary                                | statement_latency              |
| user_summary                                | statement_avg_latency          |
| user_summary                                | file_io_latency                |
| user_summary                                | current_memory                 |
| user_summary                                | total_memory_allocated         |
| host_summary_by_file_io_type                | total_latency                  |
| host_summary_by_file_io_type                | max_latency                    |
| host_summary_by_file_io                     | io_latency                     |
| host_summary_by_statement_type              | total_latency                  |
| host_summary_by_statement_type              | max_latency                    |
| host_summary_by_statement_type              | lock_latency                   |
| host_summary_by_statement_latency           | total_latency                  |
| host_summary_by_statement_latency           | max_latency                    |
| host_summary_by_statement_latency           | lock_latency                   |
| host_summary_by_stages                      | total_latency                  |
| host_summary_by_stages                      | avg_latency                    |
| host_summary                                | statement_latency              |
| host_summary                                | statement_avg_latency          |
| host_summary                                | file_io_latency                |
| host_summary                                | current_memory                 |
| host_summary                                | total_memory_allocated         |
| wait_classes_global_by_avg_latency          | total_latency                  |
| wait_classes_global_by_avg_latency          | min_latency                    |
| wait_classes_global_by_avg_latency          | avg_latency                    |
| wait_classes_global_by_avg_latency          | max_latency                    |
| wait_classes_global_by_latency              | total_latency                  |
| wait_classes_global_by_latency              | min_latency                    |
| wait_classes_global_by_latency              | avg_latency                    |
| wait_classes_global_by_latency              | max_latency                    |
| waits_by_user_by_latency                    | total_latency                  |
| waits_by_user_by_latency                    | avg_latency                    |
| waits_by_user_by_latency                    | max_latency                    |
| waits_by_host_by_latency                    | total_latency                  |
| waits_by_host_by_latency                    | avg_latency                    |
| waits_by_host_by_latency                    | max_latency                    |
| waits_global_by_latency                     | total_latency                  |
| waits_global_by_latency                     | avg_latency                    |
| waits_global_by_latency                     | max_latency                    |
| processlist                                 | statement_latency              |
| processlist                                 | lock_latency                   |
| processlist                                 | last_statement_latency         |
| processlist                                 | current_memory                 |
| processlist                                 | last_wait_latency              |
| processlist                                 | trx_latency                    |
| session                                     | statement_latency              |
| session                                     | lock_latency                   |
| session                                     | last_statement_latency         |
| session                                     | current_memory                 |
| session                                     | last_wait_latency              |
| session                                     | trx_latency                    |
| INNODB_COLUMNS                              | DEFAULT_VALUE                  |
| texturl                                     | URLID                          |
| textdemo                                    | name                           |
| texttabledemo                               | Address                        |
| searchtextdemo                              | BookName                       |
| retrievefirst40characters                   | AllWords                       |
| lastindexstring                             | yourURL                        |
| stringcontainsnumber                        | Words                          |
| occurrencesofcharacter                      | sentence                       |
| textdemo                                    | sentence                       |
| countvaluescommaseparated                   | CommaSeparatedValue            |
| removedemo                                  | Name                           |
| viewtabledemo                               | UserComments                   |
| usercommentsview                            | UserComments                   |
| userinformation                             | UserPost                       |
| avoidinserterrordemo                        | Sentence                       |
| extracttuples                               | Comments                       |
| findbestmatch                               | UserQuery                      |
| user                                        | authentication_string          |
| help_topic                                  | description                    |
| help_topic                                  | example                        |
| help_topic                                  | url                            |
| help_category                               | url                            |
| slave_relay_log_info                        | Relay_log_name                 |
| slave_relay_log_info                        | Master_log_name                |
| slave_master_info                           | Master_log_name                |
| slave_master_info                           | User_name                      |
| slave_master_info                           | User_password                  |
| slave_master_info                           | Ssl_ca                         |
| slave_master_info                           | Ssl_capath                     |
| slave_master_info                           | Ssl_cert                       |
| slave_master_info                           | Ssl_cipher                     |
| slave_master_info                           | Ssl_key                        |
| slave_master_info                           | Bind                           |
| slave_master_info                           | Ignored_server_ids             |
| slave_master_info                           | Uuid                           |
| slave_master_info                           | Ssl_crl                        |
| slave_master_info                           | Ssl_crlpath                    |
| slave_master_info                           | Tls_version                    |
| slave_master_info                           | Public_key_path                |
| slave_worker_info                           | Relay_log_name                 |
| slave_worker_info                           | Master_log_name                |
| slave_worker_info                           | Checkpoint_relay_log_name      |
| slave_worker_info                           | Checkpoint_master_log_name     |
| posts                                       | post_content                   |
| updatestringdemo                            | FileName                       |
| selectrowdemo                               | Message                        |
| findstringwithgivenprefixdemo               | UserMessage                    |
| getfileextensiondemo                        | File_Name                      |
| addtoexistingvaluedemo                      | Instructor_TechnicalSubject    |
| findreplacedemo                             | FileDirectory                  |
| trimcommasdemo                              | AllTechnicalSkills             |
| countallcharactersdemo                      | UserSubject                    |
| wheresetdemo                                | UserFavouriteSubject           |
| addexistingvaluedemo                        | StudentTechnicalSubject        |
| demotable34                                 | ProgramExtension1              |
| demotable34                                 | ProgramExtension2              |
| demotable34                                 | ImageExtension                 |
| demotable95                                 | Information                    |
| demotabel101                                | URL                            |
| demotable160                                | FileName                       |
| demotable164                                | Header                         |
| demotable165                                | Value                          |
| DemoTable                                   | CustomerAllProductPrice        |
| DemoTable                                   | Title                          |
+---------------------------------------------+--------------------------------+
240 rows in set (0.28 sec)

Updated on: 30-Jul-2019

111 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements