Results 1 to 6 of 6

Thread: Temp Tables

  1. #1
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Unanswered: Temp Tables

    Hi I have a question and it might be a silly one but what is the purpose of Temp Tables.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Nah, that's not a silly question. Let me work on it just a bit, I'm sure that I can make it silly though!

    A temp table is just what the name implies, a table that is created "on the fly" for temporary use. If created in a stored procedure, the table is dropped when the procedure exits. If created interactively, the table is dropped when the session (spid) ends. Temp tables are always created in tempdb, and the names are always mangled just a bit so that everyone on the server can create a temp table called #ickyTableNameWithLotsAndLotsOfCharacters and the system can still keep them all straight.

    How'd I do?

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by Pat Phelan
    How'd I do?
    Very informative but not nearly silly enough q
    George
    Home | Blog

  4. #4
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Smile

    Quote Originally Posted by Pat Phelan
    Nah, that's not a silly question. Let me work on it just a bit, I'm sure that I can make it silly though!

    A temp table is just what the name implies, a table that is created "on the fly" for temporary use. If created in a stored procedure, the table is dropped when the procedure exits. If created interactively, the table is dropped when the session (spid) ends. Temp tables are always created in tempdb, and the names are always mangled just a bit so that everyone on the server can create a temp table called #ickyTableNameWithLotsAndLotsOfCharacters and the system can still keep them all straight.

    How'd I do?

    -PatP
    Thank you Pat I appreciate it

  5. #5
    Join Date
    Apr 2009
    Posts
    15
    Very creative :P

    Also to expand a bit, you can create a local temp table by denoting #icky :P or you can create a global temp table by denoting ##icky...

    A global temp table can be used from within any session for a particular database.

  6. #6
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •