temp-tables

Normal table or global temp table?

本小妞迷上赌 提交于 2019-12-10 10:36:11
问题 Me and another developer are discussing which type of table would be more appropriate for our task. It's basically going to be a cache that we're going to truncate at the end of the day. Personally, I don't see any reason to use anything other than a normal table for this, but he wants to use a global temp table. Are there any advantages to one or the other? 回答1: Use a normal table in tempdb if this is just transient data that you can afford to lose on service restart or a user database if

When will data in Oracle session temporary table get deleted?

两盒软妹~` 提交于 2019-12-10 06:44:52
问题 I have read that in session tables the data survives the commit process. In words of Ask Tom. the ON COMMIT PRESERVE ROWS makes this a session based temporary table. rows will stay in this table until a logoff. Only I can see them though, no other session will ever see 'my' rows even after I commit The problem phrase for me here is "until a logoff". Take the case of a web application which maintains a single connection to DB. So this means that all users logged into the web application are

How would I create a temp table in SQL Server when I have a big list of ID's

走远了吗. 提交于 2019-12-10 03:46:52
问题 I have a list of raw IDs that I am supposed to put into a temp table. I am unsure about how this works in SQL Server: I know the general format: select PID into #myPIDs from ... ? I already have a list of about 30 PIDs which I am to use. They look like so: 'U388279963', 'U388631403', 'U389925814' How do I go about doing this? Thanks! 回答1: Your format will work for creating a new temp table for one insert. If you need to copy and paste your IDs then the following will work. CREATE TABLE

is a mysql temporary table unique for each user accessing the script that creates it…?

纵然是瞬间 提交于 2019-12-10 02:34:53
问题 While looking for a way to temporarily save the search results when a user searches for a hotel free between particular dates i came across temporary tables. But certain questions are not answered even in mysql manual.... like... Will the temporary table be unique for each user that executes the script...? Or will it be overwritten when two different users run the script at the same time...? When will the table be destroyed..? When the user closes the browser window or just navigates away

SQL Server CTE referred in self joins slow

被刻印的时光 ゝ 提交于 2019-12-09 16:26:20
问题 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

How to copy structure and contents of a table, but with separate sequence?

末鹿安然 提交于 2019-12-09 02:49:38
问题 I'm trying to setup temporary tables for unit-testing purposes. So far I managed to create a temporary table which copies the structure of an existing table: CREATE TEMP TABLE t_mytable (LIKE mytable INCLUDING DEFAULTS); But this lacks the data from the original table. I can copy the data into the temporary table by using a CREATE TABLE AS statement instead: CREATE TEMP TABLE t_mytable AS SELECT * FROM mytable; But then the structure of t_mytable will not be identical, e.g. column sizes and

Auto Increment in Temporary Table

徘徊边缘 提交于 2019-12-08 12:30:53
问题 I'm trying to create a Temp Table that has a key field that auto increments. But I keep running into a syntax error. Here's what I'm trying: CREATE TEMPORARY TABLE RETURN_ARTISTS (KEY INT(11) NOT NULL AUTO_INCREMENT, ARTIST_1_KEY INT(11), ARTIST_2_KEY INT(11)); INSERT INTO RETURN_ARTISTS (1,1); DELETE TABLE RETURN_ARTISTS; And here's the error I keep getting: Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax

In SQL Server 2008 ,is it possible to disable auto drop of global temp table

╄→гoц情女王★ 提交于 2019-12-08 10:45:32
问题 Question 1: I am using a global temp tables in SQL Server 2008. But once my connection is closed this temp is dropped. Is there any way to disable auto drop Question 2: If two connections are accessing same global temp table and another connection is trying to delete that global temp table, does SQL Server handles this synchronization properly? 回答1: You can create your global temp tables in a stored procedure and mark it with the startup option. SQL Server maintains a reference count greater

How do I use a temp table across multiple c# calls

允我心安 提交于 2019-12-08 08:19:18
问题 I have a C# application, using ADO.Net to connect to MSSQL I need to create the table (with a dynamic number of columns), then insert many records, then do a select back out of the table. Each step must be a separate C# call, although I can keep a connection/transaction open for the duration. 回答1: There are two types of temp tables in SQL Server, local temp tables and global temp tables. From the BOL: Prefix local temporary table names with single number sign (#tablename), and prefix global

Cannot add field…row size…greater than maximum allowed size

醉酒当歌 提交于 2019-12-08 06:38:15
问题 I'm seeing the following error in my MySQL logs: [Warning] InnoDB: Cannot add field `wd_field_ft_95_240` in table `tmp`.`#sql_1_0` because after adding it, the row size is 8155 which is greater than maximum allowed size (8126) for a record on index leaf page. Is this tmp database some kind of internal MySQL structure? Is this something I need to care about? 回答1: Some MySQL queries create internal temporary tables to hold partial results. As of MySQL 5.7.6, the default storage engine for