temp-tables

Create temporary table in MySQL from Java

此生再无相见时 提交于 2020-06-13 06:16:57
问题 I have this: public static void createTemporaryTable() { Statement s = null; sentence = "CREATE TEMPORARY TABLE Book (ISBN int NOT NULL, " + "title varchar(45), author varchar(45), price double, PRIMARY KEY (`ISBN`));"; try { s = Conexion.getInstancia().createStatement(); s.executeUpdate(sentence); } catch (SQLException e) { e.printStackTrace(); } finally { try { s.close(); } catch (SQLException e) { e.printStackTrace(); } } } Then: public class System { public static void main(String[] args)

Create temporary table in MySQL from Java

旧时模样 提交于 2020-06-13 06:16:10
问题 I have this: public static void createTemporaryTable() { Statement s = null; sentence = "CREATE TEMPORARY TABLE Book (ISBN int NOT NULL, " + "title varchar(45), author varchar(45), price double, PRIMARY KEY (`ISBN`));"; try { s = Conexion.getInstancia().createStatement(); s.executeUpdate(sentence); } catch (SQLException e) { e.printStackTrace(); } finally { try { s.close(); } catch (SQLException e) { e.printStackTrace(); } } } Then: public class System { public static void main(String[] args)

CTE (Common Table Expression) vs Temp tables or Table variables, which is faster?

天涯浪子 提交于 2020-06-10 02:51:28
问题 CTE (Common Table Expression) vs Temp tables or Table variables , which is faster? 回答1: We got a 50% increase in speed moving to CTE in one particular case so it's worth giving it a go but any performance related enhancements need to be bench marked so you can compare one against another. PS: we wrote more than one query with a CTE in it before we got the one we now use. 回答2: As I already said in my comment: IT DEPENDS! It really does depend on your query, your data (how much is there? What

Turning a multi-value parameter into a temp table in SQL Server Business Intelligence Development Studio

帅比萌擦擦* 提交于 2020-05-15 10:56:05
问题 I want to create a report in MS SQL Server BIDS (SSMS and Visual Studio). The user would enter a list of email addresses as a parameter. So @pEmails would be 'foo@bluh.com', 'bar@meh.org', etc. These email addresses may or may not be in a table. I can simply do: and Table.Email in (@pEmails) and that works, except I need to return the email address if it's NOT found as well. So the results would be something like: |email |found in table| |------------|--------------| |foo@bluh.com| Y | |bar

SQL Server Creating a temp table for this query

只谈情不闲聊 提交于 2020-04-06 02:24:07
问题 I have this query: DECLARE @ProjectID int = 3, @Year int = 2010, @MeterTypeID int = 1, @StartDate datetime, @EndDate datetime SET @StartDate = '07/01/' + CAST(@Year as VARCHAR) SET @EndDate = '06/30/' + CAST(@Year+1 as VARCHAR) SELECT tblMEP_Sites.Name AS SiteName, convert(varchar(10),BillingMonth ,101) AS BillingMonth, SUM(Consumption) AS Consumption FROM tblMEP_Projects JOIN tblMEP_Sites ON tblMEP_Projects.ID = tblMEP_Sites.ProjectID JOIN tblMEP_Meters ON tblMEP_Meters.SiteID = tblMEP_Sites

How MariaDB administrates temporary tables?

余生颓废 提交于 2020-03-05 00:27:29
问题 I would like to understand how MariaDB administrates temporary tables. For example, how MariaDB cope with a temporary and non-temporary table if they have both the same name. In the example below I created a temporary and non-temporary table with the same name (step A) and did an update of the table. Now, which one was updated (B)? When I drop the non-temporary table (C1) the table has no content but still exists (C1). Only after a second dropping table will be dropped. The same happens if I

PostgreSQL equivalent of MySQL memory tables?

北战南征 提交于 2020-02-17 06:58:06
问题 Does PostgreSQL have an equivalent of MySQL memory tables? These MySQL memory tables can persist across sessions (i.e., different from temporary tables which drop at the end of the session). I haven't been able to find anything with PostgreSQL that can do the same. 回答1: No, at the moment they don't exist in PostgreSQL. If you truly need a memory table you can create a RAM disk, add a tablespace for it, and create tables on it. If you only need the temporary table that is visible between

Use of temp tables in SQLite databases

梦想与她 提交于 2020-01-24 01:38:09
问题 I was browsing through the source code for Mendeley for Android by Martin Eve and saw that Temp tables are created along with the main tables by calling replace on the tables with _id. For example on the Collections table db.execSQL(COLLECTIONS_CREATE.replace(" (_id", "_TEMP (_id")); I guess it creates a new temporary table. Any more explanation on this would be great. Further on the data is first inserted to temp tables and later moved to main tables. I searched through SO and came across

SQL Server - Create temp table if doesn't exist

做~自己de王妃 提交于 2020-01-23 11:35:05
问题 In my SQL Server 2012 environment, I've created a series of stored procedures that pass pre-existing temporary tables among themselves (I have tried different architectures here, but wasn't able to bypass this due to the nature of the requirements / procedures). What I'm trying to do is to, within a stored procedure check if a temporary table has already been created and, if not, to create it. My current SQL looks as follows: IF OBJECT_ID('tempdb..#MyTable') IS NULL CREATE TABLE #MyTable (

Creating and deleting temp tables consecutively in a stored procedure

左心房为你撑大大i 提交于 2020-01-16 22:00:12
问题 This code doesn't work when I run it and I don't understand why it shouldn't, the error is that a table already exists so it doesn't seem so much as an actual bug but a bug in the verification process, perhaps I am wrong. it's something from a procedure so doesn't work to use go's everywhere. in my first question I grossly oversimplified my problem these were my constraints : I use temporary tables to communicate between procedures, in this case I needed to use the same procedure twice but