I encountered this error when I was working on a project and after searching and searching, I decided to check the database and realized that all I had exported from the database was the structure and not the structure and the data. That was what caused the error for me.
As a programmer, there are no real problems but challenges...ones that we need to overcome. This means that there is a solution for all challenges that one may face. For all the challenges that I have faced, I will share them and their solutions.
Showing posts with label database. Show all posts
Showing posts with label database. Show all posts
Friday, August 21, 2015
Tuesday, July 15, 2014
Get size of database
You can get the size of a specific database by running this command:
SELECT table_schema "Data Base Name",
SUM( data_length + index_length ) / 1024 /
1024 "Data Base Size in MB",
SUM( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
WHERE table_schema = "";
If you want to show the size of all databases on a server, then use this command:
SELECT table_schema "Data Base Name",
SUM( data_length + index_length ) / 1024 /
1024 "Data Base Size in MB",
SUM( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema ;
SELECT table_schema "Data Base Name",
SUM( data_length + index_length ) / 1024 /
1024 "Data Base Size in MB",
SUM( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
WHERE table_schema = "
If you want to show the size of all databases on a server, then use this command:
SELECT table_schema "Data Base Name",
SUM( data_length + index_length ) / 1024 /
1024 "Data Base Size in MB",
SUM( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema ;
Wednesday, June 4, 2014
Removing tables from database with a particular prefix
use the statement below to get a list of tables. you can then copy the statement and execute it. if there are alot of tables, you may have to repeat the process as often as needed.
SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' )
AS statement FROM information_schema.tables
WHERE table_schema = 'database_name' AND table_name LIKE 'myprefix_%';
replace 'database_name' with the name of your database and 'myprefix_' with the prefix that you want to delete.
Subscribe to:
Posts (Atom)
