temp-tables

A persistent temporary table?

久未见 提交于 2019-12-23 03:01:49
问题 Right now, I'm using temporary tables in my select queries to speed up the execution. They are created every time I execute the query. In my current situation, the tables are updated with new data only once per day, so I was thinking that instead of using MySQL's CREATE TEMPORARY TABLE statement, I'll create a persistent table, which in a sense would be temporary since it'd be deleted and recreated after a day. And I could fill it up with the temporary data just after I've finished updating

A persistent temporary table?

て烟熏妆下的殇ゞ 提交于 2019-12-23 03:01:27
问题 Right now, I'm using temporary tables in my select queries to speed up the execution. They are created every time I execute the query. In my current situation, the tables are updated with new data only once per day, so I was thinking that instead of using MySQL's CREATE TEMPORARY TABLE statement, I'll create a persistent table, which in a sense would be temporary since it'd be deleted and recreated after a day. And I could fill it up with the temporary data just after I've finished updating

Temp tables on the current connection

情到浓时终转凉″ 提交于 2019-12-23 01:54:26
问题 if I do: select * from tempdb.sys.tables I will see all the temporary tables in the system, however that view does not have information about which connection/user each table belongs to. I'm interested in finding only the tables I've created on my current connection. Is there a way to do this? thanks - e p.s. yes, I could try reading each table listed with the notion that those that succeed should prove to be mine (on recent versions one can't read other connections' tables) but that is too

Clustered index on temp table

痴心易碎 提交于 2019-12-22 08:47:28
问题 I'm trying to optimize a procedure that has code like the following: CREATE TABLE #t1 (c1 int, c2 varchar(20), c3(varchar(50)...) CREATE CLUSTERED INDEX ix_t1 ON #t1(c3) ON [PRIMARY] I wanted to improve that by moving the CLUSTERED index into the table declaration (more caching friendly), but c3 is not unique so this doesn't work: CREATE TABLE #t1 (c1 int, c2 varchar(20), c3 varchar(50)..., UNIQUE CLUSTERED (c3)) Is there a way to declare a clustered that is not unique in the temp table

Recommend usage of temp table or table variable in Entity Framework 4. Update Performance Entity framework

牧云@^-^@ 提交于 2019-12-20 18:43:11
问题 I need to update a bit field in a table and set this field to true for a specific list of Ids in that table. The Ids are passed in from an external process. I guess in pure SQL the most efficient way would be to create a temp table and populate it with the Ids, then join the main table with this and set the bit field accordingly. I could create a SPROC to take the Ids but there could be 200 - 300,000 rows involved that need this flag set so its probably not the most efficient way. Using the

DECLARE GLOBAL TEMPORARY TABLE Vs CREATE GLOBAL TEMPORARY TABLE in DB2

£可爱£侵袭症+ 提交于 2019-12-19 00:37:07
问题 am creating a GLOBAL TEMPORARY TABLE in DB2. and when i surfed i got a two way to create 1. Declare 2. Create. 1. DECLARE GLOBAL TEMPORARY TABLE SESSION.TEMP_EMP (EMPNO CHAR(6) NOT NULL, SALARY DECIMAL(9, 2), BONUS DECIMAL(9, 2), COMM DECIMAL(9, 2)) WITH REPLACE ON COMMIT PRESERVE ROWS ; 2. CREATE GLOBAL TEMPORARY TABLE TMPDEPT (TMPDEPTNO CHAR(3) NOT NULL, TMPDEPTNAME VARCHAR(36) NOT NULL, TMPMGRNO CHAR(6), TMPLOCATION CHAR(16) ) ON COMMIT PRESERVE ROWS ; and from IBM site i got a info that

SQL Server, temporary tables with truncate vs table variable with delete

牧云@^-^@ 提交于 2019-12-18 05:57:18
问题 I have a stored procedure inside which I create a temporary table that typically contains between 1 and 10 rows. This table is truncated and filled many times during the stored procedure. It is truncated as this is faster than delete. Do I get any performance increase by replacing this temporary table with a table variable when I suffer a penalty for using delete (truncate does not work on table variables) Whilst table variables are mainly in memory and are generally faster than temp tables

What is the difference between TEMPORARY TABLE and TABLE VARIABLE in SQL 2008?

≯℡__Kan透↙ 提交于 2019-12-18 04:46:16
问题 What is the difference between: CREATE TABLE #temp ( [ID] INT) INSERT INTO #temp SELECT ... and DECLARE @temp TABLE ( [ID] INT) INSERT @temp SELECT ... in SQL Server 2008? 回答1: Temporary tables are like ordinary tables in most characteristics, except they go into TempDB instead of the current Database, and they dissapear after limited scope, (depending on whether they are session based or global Temp Tables. But all changes to data in Temp tables is logged to the transaction log, with all the

Create temporary table in CakePHP and load it as a Model

偶尔善良 提交于 2019-12-17 20:26:38
问题 My plan is to create a temporary table using the $this->Model->query(); method then load it as a Model but I'm getting an error staying "Missing Database Table". Turning on debug to level two shows that the temporary table is success fully created but for some reason, when I try and load it as a model it doesn't work. It looks like cake doesn't even try to see if the table exists as there is no "SHOW FULL COLUMNS FROM ...' query being displayed. Not sure how to force cake to check for its

TSQL Writing into a Temporary Table from Dynamic SQL

余生颓废 提交于 2019-12-17 20:10:08
问题 Consider the following code: SET @SQL1 = 'SELECT * INTO #temp WHERE ...' exec(@SQL1) SELECT * from #temp (this line throws an error that #temp doesn't exist) Apparently this is because the exec command spins off a separate session and #temp is local to that session. I can use a global temporary table ##temp, but then I have to come up with a naming scheme to avoid collisions. What do you all recommend? 回答1: Did you try to create your template table explicitly? Create Table #temp (..) 回答2: Try