Convert an Epoch date to Readable date in MySQL

Basic format SELECT FROM_UNIXTIME(epoch) as value FROM mytable Will display in the format like 2012-01-18 05:28:03 Or if you want to format the date specifically SELECT FROM_UNIXTIME(epoch,”%Y-%m-%d”) as value FROM mytable Or to insert into a table INSERT INTO mytable VALUES (UNIX_TIMESTAMP(now())) or use YYYY-MM-DD HH:MM:SS : INSERT INTO mytable VALUES (UNIX_TIMESTAMP(‘2008-12-01 12:00:00’)) Check out […]

Get Size of Tables or Database in MySQL

Get Size of Tables in a single MySQL Database For a given schema_name (aka database) SELECT table\_name, table\_rows, data\_length, index\_length, round(((data\_length + index\_length) / 1024 / 1024),2) “Size in MB” FROM information_schema.TABLES WHERE table\_schema = “schema\_name”; Get Total size of MySQL Databases SELECT table_schema “Data Base Name”, sum( data\_length + index\_length) / 1024 / 1024 […]