Thursday, 5 January 2017

What is Stored Procedure in MySQL?

What is Stored Procedure in MySQL?

Question: What is Stored Procedure?
A Stored procedure is program in a regular computing language, stored in database. It have has a name, a parameter list, and SQL statement(s).


Question: What is the purpose of stored procedure?
A stored procedure is used to retrieve data, modify data, and delete data in database table.


Question: What is Syntax for creating stored procedure?
DELIMITER $$
CREATE    
    PROCEDURE `dbName`.`storedProcedureName`()
    BEGIN

    END$$



Question: Create simple stored procedure?
CREATE
    /*[DEFINER = { user | CURRENT_USER }]*/
    PROCEDURE `dbname`.`helloArun`() 
    BEGIN
SELECT id,user_nickname,user_email FROM `cmf_users` WHERE user_email="hello@no-spam.ws";   
    END



Question: How to call stored procedure?
call helloArun();



Question: How to list stored procedure?
SHOW PROCEDURE STATUS;



Question: How to delete stored procedure?
DROP PROCEDURE storedProcedureName



Question: How to delete stored procedure If Exist?
DROP PROCEDURE IF EXISTS storedProcedureName



Question: Create simple stored procedure with argument?
CREATE    
    PROCEDURE `dbname`.`helloArun2`(
  IN email VARCHAR(255)    
    )
    BEGIN
 SELECT id,user_nickname,user_email FROM `cmf_users` WHERE user_email=email;      

    END



Question: How to call stored procedure with parameter?
call helloArun2('arunk@no-spam.ws');



Question: How to list of stored PROCEDURE?
SHOW PROCEDURE STATUS



Question: How to remove stored PROCEDURE?
DROP PROCEDURE storedProcedureName



Question: How to remove stored PROCEDURE if exist?
DROP PROCEDURE IF EXISTS storedProcedureName


Wednesday, 28 December 2016

How to install redis on wamp server?

How to install redis on wamp server?

Question: What is Redis?
it is an open source advanced key-value database storage system like NoSQL.


Question: Why Redis is used?
Redis is used for caching to speed up application.


Question: How redis helpful in Optimization?
Redis operations can be executed on the server side and reduce the client's workload.


Question: What type of data can be stored in Redis server?
Redis store complex data structures like strings, hashes, lists, sets, sorted sets, bitmaps and hyperlogs as its key values.


Question: Why redis is fast?
Redis is inherently fast as it stores data in memory.


Question: How to install redis in wampserver?
  1. Download the redis
       A) Download Redis setup For 32 Bit System and Install
       B) Download Redis Setup for 64 Bit system and follow below steps.    
    1. Extract the zip file
    2. Place the unzip file in c:\redis
    3. Run redis-server.exe from c:\redis
    4. then Run redis-cli.exe from c:\redis
  2. Check out your php version and know whether thread safety is enabled or not(by using phpinfo()).
  3. Now we need to download the php_redis.dll. Download the php_redis.dll from PECL.
    Download as per PHP Version and thread based.
  4. Extract the zip file.
  5. Copy the php_redis.dll and paste to following folder in Wamp Server.
    wamp\bin\php\php5.x.xx\ext\
  6. Add the following line in your php.ini
    extension=php_redis.dll
  7. Re-start the wamp Server.
  8. Do phpinfo() and search redis. It will start displaying which means its Redis is installed
  9. Learn and Work with redis.



Question: How to check redis is installed Or Not?
try {
    $redis = new Redis();
    $redis->connect('localhost', 6379);
    $redis->set('name', 'Redis is Installed');
    echo $glueStatus = $redis->get('name');
    
} catch (Exception $ex) {
    echo $ex->getMessage();
}