You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tables created using the CREATE TEMP TABLE syntax are only visible to the database connection in which the CREATE TEMP TABLE statement is originally evaluated. These TEMP tables, together with any associated indices, triggers, and views, are collectively stored in a separate temporary database file that is created as soon as the first CREATE TEMP TABLE statement is seen. [...] The temporary database file used to store TEMP tables is deleted automatically when the database connection is closed using sqlite3_close().
Currently it looks like that all tabs operate on the same connection as you can't execute a SQL script twice that uses, say CREATE TEMPORARY TABLE house(name TEXT);. On second run in you'll get "Error: table house already exists". So currently temporary tables are a bit impractical, because one either needs to renames them, or wrap the script in a transaction, like this.
BEGIN;
CREATE TEMP TABLE house
(
name TEXT,
points INTEGER
);
INSERT INTO house VALUES
('Gryffindor', 100),
('Hufflepuff', 90),
('Ravenclaw', 95),
('Slytherin', 80);
SELECT * FROM house;
ROLLBACK;
But then you can just use regular tables instead, because DDLs are transactional in SQLite.
The overhead of creating the connection on each query seems close to zero for a DB stored in the browser's memory.
The text was updated successfully, but these errors were encountered:
saaj
changed the title
[RFE] Simplify working with temorary tables
[RFE] Simplify working with temporary tables
May 20, 2021
As a user of sqliteviz,
In order to use temporary tables in my SQL scripts,
I want sqliteviz to run a script in a new connection each time.
From SQLite docs on temporary tables:
Currently it looks like that all tabs operate on the same connection as you can't execute a SQL script twice that uses, say
CREATE TEMPORARY TABLE house(name TEXT);
. On second run in you'll get "Error: table house already exists". So currently temporary tables are a bit impractical, because one either needs to renames them, or wrap the script in a transaction, like this.But then you can just use regular tables instead, because DDLs are transactional in SQLite.
The overhead of creating the connection on each query seems close to zero for a DB stored in the browser's memory.
The text was updated successfully, but these errors were encountered: