In MariaDB, SHOW TABLES is een administratieve verklaring waarin de niet-TEMPORARY tabellen, sequenties en weergaven in een bepaalde database.
Syntaxis
De syntaxis gaat als volgt:
SHOW [FULL] TABLES [FROM db_name]
[LIKE 'pattern' | WHERE expr] Voorbeeld
Hier is een voorbeeld om te demonstreren:
SHOW TABLES; Resultaat:
+------------------------+ | Tables_in_krankykranes | +------------------------+ | Customers | | Dogs | | Gameshow | | OrderItems | | Orders | | PetShow | | Pets | | Products | | Vendors | | t1 | +------------------------+
Dit toont ons de tabellen in de huidige database, in dit geval de KrankyKranes database.
Toon het tabeltype
We kunnen de FULL . gebruiken modifier om het tabeltype terug te geven:
USE sakila;
SHOW FULL TABLES; Resultaat:
+----------------------------+------------+ | Tables_in_sakila | Table_type | +----------------------------+------------+ | actor | BASE TABLE | | address | BASE TABLE | | category | BASE TABLE | | city | BASE TABLE | | country | BASE TABLE | | customer | BASE TABLE | | customer_list | VIEW | | film | BASE TABLE | | film_actor | BASE TABLE | | film_category | BASE TABLE | | film_list | VIEW | | film_text | BASE TABLE | | inventory | BASE TABLE | | language | BASE TABLE | | nicer_but_slower_film_list | VIEW | | payment | BASE TABLE | | rental | BASE TABLE | | sales_by_film_category | VIEW | | sales_by_store | VIEW | | staff | BASE TABLE | | staff_list | VIEW | | store | BASE TABLE | +----------------------------+------------+
Hier schakelde ik over naar de Sakila database en voer vervolgens SHOW FULL TABLES . uit . We kunnen zien dat sommige van de geretourneerde tabellen daadwerkelijk weergaven zijn.
Zoals vermeld, retourneert de instructie tabellen, reeksen en views.
De LIKE Clausule
De LIKE clausule, indien op zichzelf aanwezig, geeft aan welke tabelnamen overeenkomen:
SHOW FULL TABLES
LIKE 'f%'; Resultaat:
+-----------------------+------------+ | Tables_in_sakila (f%) | Table_type | +-----------------------+------------+ | film | BASE TABLE | | film_actor | BASE TABLE | | film_category | BASE TABLE | | film_list | VIEW | | film_text | BASE TABLE | +-----------------------+------------+
De WHERE Clausule
De WHERE clausule kan worden gebruikt om de resultaten te filteren op basis van een bepaald criterium:
SHOW FULL TABLES
WHERE Table_type = 'BASE TABLE'; Resultaat:
+------------------+------------+ | Tables_in_sakila | Table_type | +------------------+------------+ | actor | BASE TABLE | | address | BASE TABLE | | category | BASE TABLE | | city | BASE TABLE | | country | BASE TABLE | | customer | BASE TABLE | | film | BASE TABLE | | film_actor | BASE TABLE | | film_category | BASE TABLE | | film_text | BASE TABLE | | inventory | BASE TABLE | | language | BASE TABLE | | payment | BASE TABLE | | rental | BASE TABLE | | staff | BASE TABLE | | store | BASE TABLE | +------------------+------------+
We kunnen ook de WHERE . gebruiken clausule tegen de eerste kolom met behulp van de Tables_in_dbname conventie, waarbij dbname is de naam van de database:
SHOW FULL TABLES
WHERE Tables_in_sakila = 'customer'; Resultaat:
+------------------+------------+ | Tables_in_sakila | Table_type | +------------------+------------+ | customer | BASE TABLE | +------------------+------------+