Search code examples
sqldatabasetemp-tablessap-iq

#temp_table vs user.#temp_table sybase_iq


i wonder what is the difference between #temp_table and user.#temp_table

 -- 1) #Tem_table

  create table #temp_table
   ( id integer null);

 select * from #temp_table  -- find

select * from sysobjects where name = '#temp_table'-- not found

-- close my client

 select * from #temp_table -- not found

--2) user.#temp_table
 create table user.#temp_table
   ( id integer null);

  select * from user.#temp_table  -- found


 select * from sysobjects where name = '#temp_table'  --  found

-- close my client

  select * from sysobjects where name = '#temp_table'  -- still exist

My Main question is, why

 select * from sysobjects where name = '#temp_table'

return nothing, and with user.

  select * from sysobjects where name = '#temp_table'

returns the info.


Solution

  • When you add user_name.#Table_name Sybase ignore automatically the #. What are you creating is a normal user Table. In fact if you check it with

     select * from sysobjects where name = '#temp_table'
    

    the type should be 'U' what means that you have created a user table = not temporary table at all.

    Best Regards, Enrique