How to use views in mysql 01Aug, 2014

How to use views in mysql

Views are the stored queries which produce results on being invoked. A view act as the virtual table or the prepared SQL statement. Available in MySQL Server 5.0, the view help in retrieving the data faster because you don’t have to perform joins and incorporate functions in your queries. Just create views for the data you require and see the action being performed by itself whenever the  insert, update and delete function is performed in the table. Once created, views update the data automatically. Example: Here I am going to create one table where I will store the data related to video rating and store rating calculation in view. This is done to reduce the complications of the user,by using…

How to use Cascade in MySQL 10Dec, 2013

How to use Cascade in MySQL

If you are going to make a change in one table and you want to automatically pass on the change (delete, update) to its dependents, then we use Cascade in MySQL. Let me explain this process by means of an example. Step 1: Create a ‘person’ table. This ‘person’ table must be Innodb. CREATE TABLE IF NOT EXISTS `persons` ( `id` int(11) NOT NULL AUTO_INCREMENT, `last_name` varchar(222) NOT NULL, `first_name` varchar(222) NOT NULL, `address` varchar(222) NOT NULL, `city` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; And insert some data in this table INSERT INTO `persons` (`id`, `last_name`, `first_name`, `address`, `city`) VALUES (2, ‘sharma’, ‘vikas’, ‘mohali’, ‘mohal’), (5, ‘singh’, ‘jaskaran’, ‘mullanput’, ‘mohali’); Step 2: Now create…

Posted in: MySQL
How to use MySQL from SSH (Linux shell) 12Nov, 2010

How to use MySQL from SSH (Linux shell)

Using MySQL from SSH may seem to be quite tricky if you’ve never done it before – but fear not – below is a list of MySQL commands that you can use to perform the required actions. Start by logging-in using a SSH client, like PuTTY, to access the shell command line. Below when you see # it means from the unix shell. And when you see mysql> it means from a MySQL prompt after logging into MySQL. To login (from unix shell) use -h hostname only if needed # mysql -h hostname -u root -p This would ask you for a password and after providing the correct password you’d be logged-in to the MySQL prompt. If you get an…

Posted in: MySQL, SSH