Questions tagged [temp-tables]

Temporary tables are a feature of RDBMS's as a means of storing intermediate results. Some RDBMS's make the distinction between local and global temporary tables. Temporary tables are typically dropped when the session ends for local, or when the temporary table is no longer referenced for global. Note that a temporary table is not the same as a table variable even though both are temporary in nature.

The term temporary table is somewhat misleading, because the tables are permanent, just the data is somewhat volatile.

Temporary tables are useful to store intermediate data. Since it only exists for a session or a transaction the RDBMS doesn't have to worry about locks in order to synchronize between different transactions or redo information. This makes temporary tables often faster and more efficient then normal tables.

1637 questions
0
votes
1 answer

How to drop #Temp_______hex tables?

Our Temp DB has grown very large and we'd like to clean it up. When i open the tempdb, temptables folder, I notice a like of tables named like so: #Somename________hexcode #Someothername________hexcode etc... we know we can delete them because…
A.G.
  • 2,089
  • 3
  • 30
  • 52
0
votes
2 answers

Using EXTENT SIZE + NEXT SIZE for TEMP tables will impact performance in informix DB?

I want to know if there is any performance impact if using EXTENT SIZE, NEXT SIZE while creating temp tables in Informix DB.
SuRa
  • 503
  • 2
  • 12
  • 24
0
votes
0 answers

Why I get "Copying to tmp table on disk" after several iteration of loop

Why I get "Copying to tmp table on disk" after several iteration of loop? In the first few iterations I have not this. Table has 10 million and more rows. When I set lover offset, loop execute more iteration without "tmp table". My select is SELECT…
Michal6677
  • 11
  • 2
0
votes
2 answers

Temporary tables in Stored procedure are not accesing data?

This is My code create proc TEMP AS BEGIN DECLARE @SQL nvarchar(4000) IF OBJECT_ID(N'tempdb..#TEMP1') IS NOT NULL DROP TABLE #TEMP1; SET @SQL ='SELECT CUSTOMERS,AREA,HOUSEHOLDS'+CHAR(10) SET @SQL = @SQL +'INTO…
0
votes
2 answers

Update temp table - tsql

I've got a temporary work table that i need to update the sector value where the portfolio holds bonds and cash. Currently in the work table i'll assign anything that is a bond to be "Bond" and anything to be cash to be "Cash". I have an example…
chrissy p
  • 823
  • 2
  • 20
  • 46
0
votes
2 answers

How to pass a SQL temp table to a C# stored procedure

What's the best way to pass a temp table to a C# stored procedure (SQL 2008)? Am I stuck passing the temp table name as text and running a select from C#? I was hoping to use Table Value Parameters, but they don't appear to be supported in C#…
user221606
0
votes
1 answer

Very slow query

I am completely new to mysql and have been trying to run the below mysql query, but it seems to be running incredibly slowly, taking hours. The table is about 100MB and contains about 2 million rows. Create TEMPORARY table temp_table as ( SELECT …
user2676706
  • 67
  • 2
  • 7
0
votes
1 answer

Should MySQL temp tables be indexed (or have a primary key)?

I am creating a stored procedure in MySQL which creates numerous temp tables based on the data it processes. After nearly completing the procedure I wondered...Do these temp tables created on-the-fly really need an Unique key, Primary key, or…
Cesar
  • 2,229
  • 1
  • 22
  • 20
0
votes
1 answer

Best approach? Loop through records, create a temptable, use a view?

SQL Server newbie question here! I have 3 tables, tbl_Sales, tbl_SalesItems, tbl_Products. tbl_SalesItems stores the products added to each sale, and is joined to tbl_Products by product code. Products in tbl_Products are categorised by a…
BiigJiim
  • 165
  • 1
  • 1
  • 10
0
votes
1 answer

Is this Possible?? Regarding SP's and Temp tables

I need to Update table, select rows that were updated, and then get a count on those rows. Is it possible to do this in 1 stored procedure? I'm working in a c# services app and using SQL Server. What's a good alternative if it is not doable.
CSharper
  • 5,420
  • 6
  • 28
  • 54
0
votes
2 answers

SQL Views v Stored procedures

I've just started joining Stored Procedures together using views and it seems a simple way of building up a short query using the results of others. Are there any disadvantages to over relying on Views before I plough on with this method? Am I…
Mike
  • 537
  • 1
  • 8
  • 18
0
votes
1 answer

Get the last created temporary table

In my application,i am allowing a user select as many records as possible which are then run through some tests to mark some records to leave out when adding the selected records to the final destination. To do that,i am creating a temporary table…
0
votes
1 answer

use pivot table in stored procedure

I have a pivot query that works great! ;with PivotData As ( Select KeyField, ColumnName, FieldValue FROM (SELECT SomeField as KeyField, NameField As ColumnName, DataField as FieldValue FROM Table1 UNION SELECT SomeField, NameField, DataField FROM…
Leslie
  • 3,604
  • 7
  • 38
  • 53
0
votes
1 answer

Postgresql: Function with temporary tables

I have a function which accesses temporary tables. I can create this function in a session and drop the function once application exit the session. But I do not want to recreate the function in every session. Will the function remain valid if I do…
Vishal
  • 3,189
  • 1
  • 15
  • 18
0
votes
1 answer

Postgresql: Can I override the default bahaviour of Temporary table?

In my database I have various temporary tables, I do not want to drop, which is default behaviour of temp tables, these tables after each transaction. To reduce such drop overhead, I have written following definition of the temp tables CREATE…
Vishal
  • 3,189
  • 1
  • 15
  • 18
1 2 3
99
100