Archive

Posts Tagged ‘SQL’

Actual size of tables for tablespaces

November 5th, 2011 No comments

The size of a table can be found using oracle’s segment tables. Basically following code block returns a result of table size within related tablespaces in terms of MB and GB:

   SELECT tablespace_name,
          segment_name AS TABLENAME,
          trunc((sum(BYTES) / 1024 / 1024), 2) MB,
          trunc((sum(BYTES) / 1024 / 1024 / 1024), 2) GB
     FROM user_segments
 GROUP BY tablespace_name, segment_name

This way you may access only the tablespaces of logged in user

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: +8 (from 10 votes)

How to Backup and Restore a MySQL Database

June 7th, 2009 1 comment

To make a database backup using the MySQL command-line utilities, execute the following command:

$ mysqldump -u username -p –opt dbname > dump.sql

It will ask you for password because we used -p paramater over there. If the MySQL programs are not in your path, you will need to manually specify the location of the mysqldump program:

$ /path-to-your-mysql-bin/mysqldump -u username -p –opt dbname > dump.sql

Download the dump.sql and keep it in a safe place (CDR, Zip disk, etc).

If you need to restore your database, you can do so like this:

$ mysql -u username -p dbname < dump.sql

This is the simples way to restore and backup your database.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Categories: General Tags: ,