cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Difference between CREATE LOCAL TEMPORARY COLUMN TABLE and CREATE LOCAL TEMPORARY TABLE

kgaurav2k14
Participant
0 Likes
4,921

Hi Friends,

I came across CREATE LOCAL TEMPORARY TABLE and found that we can do delete and update operations on it whereas we cannot do any modification to the table created by CREATE LOCAL TEMPORARY COLUMN TABLE.

which one is better for usage in the SQL stored procedure and why? What if I always use CREATE LOCAL TEMPORARY TABLE? Is there any disadvantage?

Thanks,

Gaurav

View Entire Topic
Vitaliy-R
Developer Advocate
Developer Advocate
0 Likes

Hi Gaurav. Seems there is an issue with the 2.0 SPS3 documentation because it says that the COLUMN table should be created by default, but I checked and indeed it is ROW table created in case of LOCAL TEMPORARY...

CREATE LOCAL TEMPORARY COLUMN TABLE "#TEST_TABLE1" (ID INTEGER, NAME VARCHAR(10)); 
CREATE LOCAL TEMPORARY  TABLE "#TEST_TABLE2" (ID INTEGER, NAME VARCHAR(10)); 
CREATE LOCAL TEMPORARY ROW TABLE "#TEST_TABLE3" (ID INTEGER, NAME VARCHAR(10)); 


SELECT TABLE_NAME, "IS_COLUMN_TABLE" FROM M_TEMPORARY_TABLES
WHERE TABLE_NAME LIKE '%TEST%'
ORDER BY 1;

returns

TABLE_NAME  |IS_COLUMN_TABLE|
------------|---------------|
#TEST_TABLE1|TRUE           |
#TEST_TABLE2|FALSE          |
#TEST_TABLE3|FALSE          |

And per https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.03/en-US/20d58a5f75191014b2fe92141b... indeed row temporary table allows you to do Delete/Update/Upsert, that is not possible on column temporary table.

The description was fixed in the documentation for SP 04: "If neither ROW nor COLUMN is specified, the default ROW for temporary tables (local and global), and COLUMN for non temporary tables." https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.04/en-US/20d58a5f75191014b2fe92141b...