table

How to restore a single table in MySQL

Just look at the following example, test_presentation is the database where i am inserting serchkeylog.sql. [root@pds1 /]# mysql -u root -p test_presentation <searchkeylog.sql Enter password:*****

How to Compare Two Tables to Find Unmatched Records

One of the fastest and easiest ways to do so is using UNION. The idea is we use UNION to union two tables on all columns which we want to compare. Then we group the union on all columns which we want to compare. If the all columns are identical we get COUNT (*) equal [...]

OPTIMIZE TABLE syntax – MySQL

OPTIMIZE TABLE tbl_name OPTIMZE TABLE should be used if you have deleted a large part of a table or if you have made many changes to a table with variable-length rows (tables that have VARCHAR, BLOB or TEXT columns). Deleted records are maintained in a linked list and subsequent INSERT operations reuse old record positions. [...]

ALTER TABLE syntax – MySQL

ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec ...] alter_specification: ADD [COLUMN] create_definition [FIRST | AFTER column_name ] or ADD INDEX [index_name] (index_col_name,…) or ADD PRIMARY KEY (index_col_name,…) or ADD UNIQUE [index_name] (index_col_name,…) or ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT} or CHANGE [COLUMN] old_col_name create_definition or MODIFY [COLUMN] create_definition or DROP [COLUMN] col_name [...]

How to Run Remote Commands with SSH

The ssh program can  be used for monitoring remote hots. The system admin can also execute commands from his desktop which can be executed at remote servers. This is a cool facility of ssh. We can do much more on SSH. root@admin:~ # ssh root@www ‘df -h’ Filesystem Size Used Avail Use% Mounted on /dev/ubda 3.5G 2.1G [...]

How To List Down Linux Partition Tables

At times, listing down all partition tables and mounted linux devices gives us a better view of what storage devices and partition types does your linux box have. Here’s a simple approach on how to list down all linux partition tables and devices from your linux box. List Down Linux Partition Tables Simply issue # [...]

How to Monitor MySQL’s performance

Here are some ideas, how you can monitor the database performance of your MySQL installation. Monitoring is always an iterative and continuous process. You need to learn what patterns are OK for your database and what are the signs of slight problems or even dangerous situations. Below are the main items you can use to [...]

How to Create tables in Mysql – PHP & MySQL Code

Before you can enter data (rows) into a table, you must first define what kinds of data will be stored (columns). We are now going to design a MySQL query to summon our table from database land. In future lessons we will be using this table, so be sure to enter this query correctly! PHP [...]

How to convert a table from one storage engine to another in MySQL

 MySQL supports several storage engines that act as handlers for different table types. MySQL storage engines include both those that handle transaction-safe tables and those that handle non-transaction-safe tables: MyISAM manages non-transactional tables. It provides high-speed storage and retrieval, as well as fulltext searching capabilities. MyISAM is supported in all MySQL configurations, and is the default storage engine [...]

Database Replication in MySQL – Step by Step Guide

Replication enables data from one MySQL database server (called the master) to be replicated to one or more MySQL database servers (slaves). Replication is asynchronous – your replication slaves do not need to be connected permanently to receive updates from the master, which means that updates can occur over long-distance connections and even temporary solutions [...]

How to Run quotacheck command

When each quota-enabled file system is remounted, the system is now capable of working with disk quotas. However, the file system itself is not yet ready to support quotas. To do this, you must first run quotacheck. The quotacheck command examines quota-enabled file systems, building a table of the current disk usage for each one. This table is [...]

How to View The Contents Of A Table

You can view all the data contained in the table named test by using the select command. In this example you want to see all the data contained in the very first row in the table. mysql> select * from test limit 1; With a brand new database this will give a blank listing, but [...]

How to View MySQL Database’s Table Structure

The describe command gives you a list of all the data fields used in your database table. In the example, you can see that the table named test in the salesdata database keeps track of four fields: name, description, num, and date_modified. mysql> describe test; +—————+————–+——+—–+————+—————-+ | Field | Type | Null | Key | [...]

How to List the Data Tables In Your MySQL Database

The show tables command gives you a list of all the tables in your MySQL database, but you have to use the use command first to tell MySQL to which database it should apply the show tables command. The example uses the salesdata database; notice that it has a table named test. mysql> use salesdata; [...]

How to Run MySQL Scripts To Create Data Tables

Another common feature of prepackaged applications written in MySQL is that they may require you to not only create the database, but also to create the tables of data inside them as part of the setup procedure. Fortunately, many of these applications come with scripts you can use to create the data tables automatically. Usually [...]