Posts

Showing posts from April, 2010

Date Time Operation in MySql

##Convert Time Zone### ->SELECT CONVERT_TZ('2004-01-01 12:00:00','GMT','MET'); ->SELECT CONVERT_TZ('2004-01-01 12:00:00','+00:00','+10:00');   /////////////////////BESIC FUNTION FOR SYSTEM DATE & TIME/////////////// #Select Now Function ->SELECT now(); #Now Function With SLEEP ->SELECT NOW(), SLEEP(3), NOW(); #SYSDATE WITH SLEEP ->SELECT SYSDATE(), SLEEP(2), SYSDATE(); #Select Current Date ->SELECT CURDATE(); #Select Current Date ->SELECT CURTIME(); #Find Number Of Days Between Two Date ->SELECT DATEDIFF('2007-06-26 23:59:59','2007-04-20'); #Return Day Of Week ->SELECT DAYOFWEEK('2007-02-03'); #Return Day Of Year ->SELECT DAYOFYEAR('2007-02-03'); #Extract Function::::EXTRACT(unit FROM date) ->SELECT EXTRACT(YEAR FROM '2007-06-26'); #Extract YEAR & MONTH ->SELECT EXTRACT(YEAR_MONTH FROM '2001-06-26 01:02:03'); #Extract DAY & MINUTE ->S...

Install MySql On Linux

You can download MySQL package from http://dev.mysql.com/downloads/ Install Mysql On Linux: Please run below commands on linux terminal. 1-Yum installetion process           yum install mysql          yum install mysql-server          yum install mysql-client          yum install mysql-devel 2-RPM installetion process           rpm -ivh mysql-FILENAME.rpm          rpm -ivh mysql-server-FILENAME.rpm          rpm -ivh mysql-client          rpm -ivh mysql-devel Start Mysql On & OFF Lnux          chkconfig mysql on          chkconfig...

Trigger and Procedure in MySql

Image
MySQL Triggers:Auto-generate additional information in the database TRIGGER: A trigger is a database object that is  attached  to a table. In many aspects it is similar to a stored procedure. As a matter of fact, triggers are often referred to as a "special kind of stored procedure." The main difference between a trigger and a stored procedure is that the former is attached to a table and is only  fired when an INSERT, UPDATE or DELETE occurs. You specify the modification action(s) that fire the trigger when it is created.  NOW QUERY WILL BE: DELIMITER $$ create trigger before_student_update BEFORE update ON student_04 for each row Begin insert into trigger_demo set action='UPDATE',date_time=now(),phone_no=OLD.phone_no; END; $$ DELIMITER ; DROP TRIGGER The general syntax of DROP TRIGGER is :          DROP TRIGGER trigger_name PROCEDURE: A  stored procedure  or in simple a  proc  is a named PL/SQL ...