temp-tables

Alternate method to global temp tables for Oracle Stored Procedure

青春壹個敷衍的年華 提交于 2019-12-04 06:16:06
问题 I have read and understand that Oracle uses only global temp tables unlike MS SQL which allows #temp tables. The situation that I have would call for me to create hundreds of Global temp tables in order to complete the DB conversion I am working on from MS SQL to Oracle. I want to know if there is another method out there, within a Oracle Stored Procedure, other than creating all of these tables which will have to be maintained in the DB. Thank You 回答1: " Most of the time the only thing the

MySQL user created temporary table is full

删除回忆录丶 提交于 2019-12-04 04:56:09
I have a created a temporary table using the memory engine as followed: CREATE TEMPORARY TABLE IF NOT EXISTS some_text ( id INT DEFAULT 0, string varchar(400) DEFAULT '' ) engine = memory; When I insert rows into it I run into a #1114 error because the table is full. It explains in the mysql docs that changing the tmp_table_size and the max_heap_table_size don't do anything for increasing the size of user created temp tables, which is what I think I have here. How do I go about making this table larger? I would love to be able to do this dynamically with a call to SET, but I've tried setting

Alternative for a MySQL temporary table in Oracle

喜你入骨 提交于 2019-12-04 04:36:57
问题 I noticed that the concept of temporary tables in these two systems is different, and I have a musing.. I have the following scenario in MySQL: Drop temporary table 'a' if exists Create temporary table 'a' Populate it with data through a stored procedure Use the data in another stored procedure How can I implement the same scenario in Oracle? Can I (in one procedure preferable) create a temporary table, populate it, and insert data in another (non-temporary) table? I think that I can use a

SQL Server CTE referred in self joins slow

最后都变了- 提交于 2019-12-04 03:20:06
I have written a table-valued UDF that starts by a CTE to return a subset of the rows from a large table. There are several joins in the CTE. A couple of inner and one left join to other tables, which don't contain a lot of rows. The CTE has a where clause that returns the rows within a date range, in order to return only the rows needed. I'm then referencing this CTE in 4 self left joins, in order to build subtotals using different criterias. The query is quite complex but here is a simplified pseudo-version of it WITH DataCTE as ( SELECT [columns] FROM table INNER JOIN table2 ON [...] INNER

How to convert list of numbers into (temp) table using SQL (SQL Server)

强颜欢笑 提交于 2019-12-04 01:30:14
问题 Here is an example; I have list of numbers (1,5,8,36) and I want these values as a (temp) table rows. One of the way to do is as follow select 1 as n into ##temp union select 5 as n union select 8 as n union select 36 as n The problem is number list is dynamic . it can have any no of values. So I need a proper systematic way to convert these values into temp table rows. 回答1: A solution I use alot... Supply your list of numbers as a VARCHAR(MAX) comma delimeted string, then use one of the many

Are indexes on temporary tables deleted when the table is deleted?

那年仲夏 提交于 2019-12-03 23:23:24
问题 Would the following SQL remove also the index - or does it have to be removed separately? CREATE TABLE #Tbl (field int) CREATE NONCLUSTERED INDEX idx ON #Tbl (field) DROP TABLE #Tbl 回答1: Yes they are. You can search in MSSQL help for CREATE INDEX article it is said there: "Indexes can be created on a temporary table. When the table is dropped or the session ends, all indexes and triggers are dropped." 回答2: It will be removed automatically, as there is nothing left to index. Think of it as a

SQL server temporary tables vs cursors

冷暖自知 提交于 2019-12-03 15:01:09
问题 In SQL Server stored procedures when to use temporary tables and when to use cursors. which is the best option performance wise? 回答1: If ever possible avoid cursors like the plague. SQL Server is set-based - anything you need to do in an RBAR (row-by-agonizing-row) fashion will be slow, sluggish and goes against the basic principles of how SQL works. Your question is very vague - based on that information, we cannot really tell what you're trying to do. But the main recommendation remains:

How to access dataset in current scope generated by a call to a stored procedure in TSQL?

百般思念 提交于 2019-12-03 12:45:29
Problem Background Generating and accessing data of a fixed column layout is easy. You can create local temp tables up-front, and populate them by calling stored procedures. On the other hand, if you want to generate data with a dynamic column layout, you must generally build an SQL statement dynamically and execute it with "exec sp_executesql". Since the data layout is unknown at run-time, you cannot create a temp-table up-front, and once inside the "exec sp_executesql" statement, any temporary tables created there are bound to that scope and vanish when the call returns, so it's much more

Are temporary tables thread-safe?

血红的双手。 提交于 2019-12-03 11:27:28
问题 I'm using SQL Server 2000, and many of the stored procedures it use temp tables extensively. The database has a lot of traffic, and I'm concerned about the thread-safety of creating and dropping temp tables. Lets say I have a stored procedure which creates a few temp tables, it may even join temp tables to other temp tables, etc. And lets also say that two users execute the stored procedure at the same time. Is it possible for one user to run the sp and which creates a temp table called #temp

TSQL Define Temp Table (or table variable) Without Defining Schema?

怎甘沉沦 提交于 2019-12-03 08:09:00
问题 Is there a way to define a temp table without defining it's schema up front? 回答1: Actually using a table VARIABLE, an in-memory table, is the optimal way to go. The #table creates a table in temp db, and ##table is global - both with disk hits. Consider the slow-down/hit experienced with the number of transactions. CREATE PROCEDURE [dbo].[GetAccounts] @AccountID BIGINT, @Result INT OUT, @ErrorMessage VARCHAR(255) OUT AS BEGIN SET NOCOUNT ON; SET @Result = 0 SET @ErrorMessage = '' DECLARE @tmp