Reputation: 16656
If there is a complicated query that I want to perform multiple times, is there a way to store it as an "alias"? For example, store:
SELECT
table_schema "Data Base Name",
SUM( data_length + index_length) / 1024 / 1024 "Data Base Size in MB"
FROM information_schema.TABLES
GROUP BY table_schema ;
as
GET_DB_SIZES
Is something like that possible???
Upvotes: 2
Views: 208
Reputation: 13700
One option is to put resultset in a temporary table and use it further
Upvotes: -1
Reputation: 126035
Yes, create a VIEW
:
CREATE VIEW GET_DB_SIZES AS <your query>;
Then you can:
SELECT * FROM GET_DB_SIZES;
Upvotes: 7