SQL List All Tables
Summary: in this tutorial, you will learn how to use commands to list all tables of a database in various database management systems.
Each database system has its own command to show all tables in a specified database. Here you can find the respective SQL command to list all tables in MySQL, PostgreSQL, Oracle, SQL Server, DB2, and SQLite.
SQL command to list all tables in MySQL
To list all tables in MySQL, first, you connect to the MySQL database server using the following command:
MySQL then prompts for the password; just enter the correct one for the user and press enter.
After that, select a database to work with:
And finally, issue the SHOW TABLES command to display all tables in the current database:
SQL command to list all tables in Oracle
In Oracle, you can use the SQL*Plus or SQL Developer connect to the Oracle Database server and show all tables in a database. Then issue one of the following SQL statement:
1) Show all tables owned by the current user:
2) Show all tables in the current database:
3) Show all tables that are accessible by the current user:
SQL command to list all tables in PostgreSQL
For PostgreSQL, you can use the psql command-line program to connect to the PostgreSQL database server and display all tables in a database.
First, connect to the PostgreSQL Database server:
PostgreSQL will prompt for the password; just enter the correct one and press enter.
Then, issue the following command to show all tables in the current database:
If you want to display also the size and description of the tables, you the following command:
SQL command to list all tables in SQL Server
In SQL Server, you can use the following query to find all tables in the currently connected database:
SQL command to list all tables in DB2
First, connect to a specific database on the DB2 database server:
Second, to list all table in the current database schema, you use the following command:
To list all tables, you use the command below:
SQL command to list all tables in SQLite
To show all tables in the current SQLite database, you use the following command:
If you want to query the tables based on a specific pattern e.g., all tables whose names start with test , you use the following command:
In this tutorial, you have learned commands to show all tables in a database in various database systems including MySQL, PostgreSQL, Oracle, SQL Server, DB2, and SQLite.
Просмотр списка таблиц в базе данных MySQL
При управлении серверами баз данных MySQL одна из наиболее частых задач, которые вы выполняете, — это знакомство со средой. Это включает в себя перечисление баз данных, которые находятся на сервере, отображение таблиц базы данных или получение информации об учетных записях пользователей и их привилегиях .
В этой статье показано, как вывести список таблиц в базе данных MySQL или MariaDB через командную строку.
Показать таблицы MySQL
Чтобы получить список таблиц в базе данных MySQL, используйте клиентский инструмент mysql для подключения к серверу MySQL и выполните команду SHOW TABLES .
Доступ к серверу MySQL:
Из оболочки MySQL переключитесь на базу данных с помощью оператора USE :
Выполните следующую команду, чтобы получить список всех таблиц и представлений в текущей базе данных:
Результат будет выглядеть примерно так:
Необязательный модификатор FULL покажет тип таблицы как второй выходной столбец.
Результат будет выглядеть примерно так:
Чтобы получить список таблиц без переключения на базу данных, используйте предложение FROM или IN , за которым следует имя базы данных:
Предложение LIKE можно использовать для фильтрации вывода команды SHOW TABLES соответствии с определенным шаблоном.
Например, следующий оператор вернет все базы данных, имена которых начинаются с ‘open’:
Знак процента ( % ) означает ноль, один или несколько символов.
Показать таблицы MySQL из командной строки
Чтобы получить информацию о таблицах из оболочки Linux, вы можете использовать команду mysql -e или команду mysqlshow которая отображает информацию о базах данных и таблицах.
Это особенно полезно, когда вы хотите работать со своими базами данных MySQL с помощью сценариев оболочки.
Выполните следующую команду на своем терминале, чтобы отобразить список всех баз данных:
В результате отобразится список всех таблиц:
Вот пример использования команды mysqlshow :
Вы можете отфильтровать вывод с помощью команды grep .
Выводы
Чтобы получить информацию о таблицах в базе данных MySQL, используйте команду SHOW TABLES .
Как показать таблицу в sql
In this article, we will discuss all the methods to list all tables in the oracle SQL Database.
We have three types of a subset of tables available to use as identifiers which in turn help us to sort the required table names. Here, are the following types of table identifiers in the Oracle SQL Database.
1. DBA_tables:
If the user is SYSTEM or has access to dba_tables data dictionary view, then use the given below query:
Query:
This query returns the following list of tables that contain all the tables that are there in the entire database.
Output:

2. All_tables:
If the user does not have access or privilege to view the dba_tables it can still get a list of all the tables that it has access to using the following SQL query. This SQL query gives the list of tables that can be accessed by the user along with its owner.
Query:
This query returns the following list of tables that contain all the tables that the user has access to in the entire database.
Output:

3. User_tables
If the user wants the list of all tables owned/created by him only, then use the following SQL query to get a list of tables. The following query does not return the name of the owner as it is the user itself for all the tables.
Query:
This query returns the following list of tables that contain all the tables owned by the user in the entire database.
SHOW TABLES
SHOW TABLES lists the non- TEMPORARY tables, sequences and views in a given database.
The LIKE clause, if present on its own, indicates which table names to match. The WHERE and LIKE clauses can be given to select rows using more general conditions, as discussed in Extended SHOW. For example, when searching for tables in the test database, the column name for use in the WHERE and LIKE clauses will be Tables_in_test
The FULL modifier is supported such that SHOW FULL TABLES displays a second output column. Values for the second column, Table_type , are BASE TABLE for a table, VIEW for a view and SEQUENCE for a sequence.
You can also get this information using:
See mysqlshow for more details.
If you have no privileges for a base table or view, it does not show up in the output from SHOW TABLES or mysqlshow db_name .