on ‎2020 Sep 28 11:54 AM
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
Request clarification before answering.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gaurav,
Local temporary tables created using the CREATE LOCAL TEMPORARY TABLE statement remain until they are either explicitly dropped, or until the connection closes. Local temporary tables created in IF statements using CREATE LOCAL TEMPORARY TABLE also persist after the IF statement completes.
Tables created using CREATE LOCAL TEMPORARY TABLE do not appear in the SYSTABLE view of the system catalog.
I would suggest checking KBA 2800007 - FAQ: SAP HANA Temporary Tables for further details on creating the different types of temporary tables on SAP HANA. It also states typical errors and bugs regarding temporary tables.
For "CREATE LOCAL TEMPORARY TABLE", a known bug is identified and it is described by SAP Note 2568196 - CREATE LOCAL TEMPORARY TABLE Statement Gets Rolled Back by ROLLBACK.
Best Regards,
Anna Szalay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anna,
Thanks for your reply. I think you misunderstood my question, may be I didn't put it the right way. Let me rephrase it. I want to know the difference between the temporary tables created by
1. CREATE LOCAL TEMPORARY COLUMN TABLE
AND
2. CREATE LOCAL TEMPORARY TABLE
if you note that 2nd table is not a column table. However, we can do update and delete operation on this 2nd table which we cannot do it in temporary column table. I want to know the usage level information on which one to use when and why SAP has given update and delete operation capability to table created by CREATE LOCAL TEMPORARY TABLE and not created by CREATE LOCAL TEMPORARY COLUMN TABLE statement.
Thanks,
Gaurav
HDB 2.0 SP3
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.