简体   繁体   中英

SNOWFLAKE: Cannot read temporary tables with IDataReader

Is it possible to read temporary tables using IDataReader? I am connecting to Snowflake through ODBC.

//e.g.
CREATE TEMPORARY TABLE TEMPTABLE1 (ID INT);

sting query = "SELECT * FROM DB1.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'LOCAL TEMPORARY' OR TABLE_TYPE = 'GLOBAL TEMPORARY' OR TABLE_TYPE = 'TEMPORARY' OR TABLE_TYPE = 'VOLATILE'";
using (IDataReader reader = Connection.Query(query, null))
{
    while (reader.Read()) {...}
}

Reader is empty, did I make mistake somewhere, or there is some technical limitations on this one?

You are creating the temporary table and THEN you are connecting with IDataReader afterwards. Thats why you don't see the table - its another session and temporary tables only exist within the session in which they were created.

https://docs.snowflake.com/en/user-guide/tables-temp-transient.html#temporary-tables

Temporary tables are visible in context of the same session.

Optional Parameters :

 TEMP[ORARY] | LOCAL TEMP[ORARY] | GLOBAL TEMP[ORARY] | VOLATILE

Specifies that the table is temporary. A temporary table persists only for the duration of the user session in which it was created and is not visible to other users.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM