Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Temporary tables

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 618
    Comment on it

    MySQL Temporary tables:

    • A temporary table allows a user to store temporary records and we can use these records several times until the session does not expire. They are useful in those situations when it is expensive to write a query having single SELECT Statement with Join clauses with it.

     

    • We use CREATE TEMPORARY TABLE statement to create a temporary table and we can use Drop Table statement to drop a temporary table.

    Example:
     

    CREATE TEMPORARY TABLE EMP
    
    SELECT EMPID,
    
           EMPName,
    
           Salary
    
    FROM Employee
    
    GROUP BY EMPName
    
    ORDER BY Salary DESC
    
    LIMIT 10

    The above query will create a temporary table EMP which is created from Employee table.

    Example to drop a temporary table:

    DROP TEMPORARY TABLE  EMP;

    We can easily drop a temporary table using Drop Temporary Table statement but if we try to delete a permanent table using Drop Temporary Table statement then there will be a error.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: