⌘K ctrl+k
Search Shortcut cmd + k | ctrl + k
DuckDB 2.0 ドキュメント 全文検索
per page, with , order by , clip by
Results of 1 - 10 of about 133 for insert (0.001 sec.)
INSERT Statement 12567
The INSERT statement inserts new data into a table. Examples Insert the values 1, 2, 3 into tbl : INSERT INTO tbl VALUES (1), (2), (3); Insert the result of a query into a table: INSERT INTO tbl SELECT * FROM other_tbl; Insert values into t ... he i column, inserting the default value into other columns: INSERT INTO tbl (i) VALUES (1), (2), (3); Explicitly insert the default value int ... o a column: INSERT INTO tbl (i) VALUES (1), (DEFAULT), (3); Assuming tbl has a primary key/unique constraint, do nothing on conflict: INSERT ... OR IGNORE INTO tbl (i) VALUES (1); Or update the table with the new values instead: INSERT OR REPLACE INTO tbl (i) VALUES (1); Syntax INSERT INTO inserts new rows into a table. One can insert one or more rows spec ...
https://man.mtool.work/duckdb/2.0/sql/statements/insert.html
Constraints 10573
In SQL, constraints can be specified for tables. Constraints enforce certain properties over data that is inserted into a table. Constraints can be specified along with the schema of the table as part of the CREATE TABLE statement . In cert ... contain spaces using the following CHECK constraint. CREATE TABLE students (name VARCHAR CHECK (NOT contains(name, ' '))); INSERT INTO students VALUES ('this name contains spaces'); Constraint Error: CHECK constraint failed on table students with expre ... L to a column definition enforces that a column cannot contain NULL values. CREATE TABLE students (name VARCHAR NOT NULL); INSERT INTO students VALUES (NULL); Constraint Error: NOT NULL constraint failed: students.name Primary Key and Unique Constraint ... st one row contains the given values for the set of columns. CREATE TABLE students (id INTEGER PRIMARY KEY, name VARCHAR); INSERT INTO students VALUES (1, 'Student 1'); INSERT INTO students VALUES (1, 'Student 2'); Constraint Error: Duplicate key "id: ...
https://man.mtool.work/duckdb/2.0/sql/constraints.html
INSERT Statements 10307
INSERT statements are the standard way of loading data into a relational database. When using INSERT statements, the values are supplied row-by-row. While simple, there is significant overhead involved in parsing and processing individual INSERT ... NSERT statements. This makes lots of individual row-by-row insertions very inefficient for bulk insertion. Bestpractice As a rule-of-thumb, avoid using lots of individual row-by-row INSERT ... statements when inserting more than a few rows (i.e., avoid using INSERT statements as part of a loop). When bulk inserting data, try to maximize ... the amount of data that is inserted per statement. If you must use INSERT statements to load data in a loop, avoid executing the statements in auto-commit m ...
https://man.mtool.work/duckdb/2.0/data/insert.html
CREATE TRIGGER Statement 10138
New The CREATE TRIGGER feature was introduced in DuckDB 2.0. The CREATE TRIGGER statement registers a trigger: a set of SQL statements that run automatically in response to INSERT , UPDATE , or DELETE events on a table. Examples Record ever ... val INTEGER); CREATE TRIGGER trg_audit AFTER UPDATE ON target REFERENCING OLD TABLE AS o NEW TABLE AS n FOR EACH STATEMENT INSERT INTO audit SELECT n.id, o.val, n.val FROM o JOIN n ON o.id = n.id; INSERT INTO target VALUES (1, 10), (2, 20); UPDATE targ ... rough the NEW and OLD qualifiers: CREATE TABLE t (id INTEGER); CREATE TABLE log (id INTEGER); CREATE TRIGGER trg_log AFTER INSERT ON t FOR EACH ROW INSERT INTO log VALUES (NEW.id); INSERT INTO t VALUES (1), (2); SELECT * FROM log; Restrict a trigger to ... changes of specific columns with UPDATE OF : CREATE TRIGGER trg_price AFTER UPDATE OF price ON products FOR EACH STATEMENT INSERT INTO price_changes DEFAULT VALUES; Drop a trigger: DROP TRIGGER trg_audit ON target; Drop a trigger if it exists: DROP TRI ...
https://man.mtool.work/duckdb/2.0/sql/statements/create_trigger.html
Import Data 8712
Overview DuckDB-Wasm has multiple ways to import data, depending on the format of the data. Importing happens in two steps. The data file is registered in a virtual file system using one of the register functions ( registerFileBuffer , regi ... e object ( db ), because a registered file is visible to every connection. The data is loaded into DuckDB using one of the insert functions ( insertArrowFromIPCStream , insertArrowTable , insertCSVFromPath , insertJSONFromPath ), which are called on a ... uet, JSON, or Wasm-flavored httpfs extensions can read a registered — or remote — file directly from a FROM SQL query, and INSERT statements can load values inline. The examples below all use a connection named conn , opened from the db object created ... when you instantiate DuckDB-Wasm . Opening and Closing a Connection Every insert and query runs on a connection. Open one with connect() , and close it when you are done to release memory: // Create a ne ...
https://man.mtool.work/duckdb/2.0/clients/wasm/data_ingestion.html
Indexes 8664
Index Types DuckDB has two built-in index types. Indexes can also be defined via extensions . Min-Max Index (Zonemap) A min-max index (also known as zonemap or block range index) is automatically created for columns of all general-purpose d ... dexed columns and columns that cannot be updated in place are transformed into a DELETE of the original row followed by an INSERT of the updated row. This rewrite has performance implications, particularly for wide tables, as entire rows are rewritten ... DuckDB's standard vector size, which is 2048 by default. The UPDATE statement is rewritten into a DELETE , followed by an INSERT . This rewrite happens per chunk of data (2048 rows) moving through DuckDB's processing pipeline. When updating i = 2047 t ... use we have not yet seen that chunk. Thus, we throw a constraint violation. CREATE TABLE my_table (i INTEGER PRIMARY KEY); INSERT INTO my_table SELECT range FROM range(3_000); UPDATE my_table SET i = i + 1; Constraint Error: Duplicate key "i: 2048" vio ...
https://man.mtool.work/duckdb/2.0/sql/indexes.html
CREATE TABLE Statement 8531
The CREATE TABLE statement creates a table in the catalog. Examples Create a table with two integer columns ( i and j ): CREATE TABLE t1 (i INTEGER, j INTEGER); Create a table with a primary key: CREATE TABLE t1 (id INTEGER PRIMARY KEY, j V ... n the table. CREATE TABLE t1 ( id INTEGER PRIMARY KEY, percentage INTEGER CHECK (0 <= percentage AND percentage <= 100) ); INSERT INTO t1 VALUES (1, 5); INSERT INTO t1 VALUES (2, -1); Constraint Error: CHECK constraint failed: t1 INSERT INTO t1 VALUES ... onstraint Error: CHECK constraint failed: t1 CREATE TABLE t2 (id INTEGER PRIMARY KEY, x INTEGER, y INTEGER CHECK (x < y)); INSERT INTO t2 VALUES (1, 5, 10); INSERT INTO t2 VALUES (2, 5, 3); Constraint Error: CHECK constraint failed: t2 CHECK constraint ... AINTS clause: CREATE TABLE t3 ( id INTEGER PRIMARY KEY, x INTEGER, y INTEGER, CONSTRAINT x_smaller_than_y CHECK (x < y) ); INSERT INTO t3 VALUES (1, 5, 10); INSERT INTO t3 VALUES (2, 5, 3); Constraint Error: CHECK constraint failed: t3 Foreign Key Cons ...
https://man.mtool.work/duckdb/2.0/sql/statements/create_table.html
Import from Pandas 8193
CREATE TABLE ... AS and INSERT INTO can be used to create a table from any query. We can then create tables or insert into existing tables by referring to the Pandas DataFrame in the query. There is no need to register the DataFrames manual ... kdb.sql connects to the default in-memory database connection duckdb.sql("CREATE TABLE my_table AS SELECT * FROM my_df") # insert into the table "my_table" from the DataFrame "my_df" duckdb.sql("INSERT INTO my_table SELECT * FROM my_df") If the order o ... f columns is different or not all columns are present in the DataFrame, use INSERT INTO ... BY NAME : duckdb.sql("INSERT INTO my_table BY NAME SELECT * FROM my_df") Alternatively, the append method appends ...
https://man.mtool.work/duckdb/2.0/guides/python/import_pandas.html
Multiple Python Threads 8144
This page demonstrates how to simultaneously insert into and read from a DuckDB database across multiple Python threads. This could be useful in scenarios where new data is flowing in and an analysis should be periodically re-run. Note that ... imported prior to the multi-threading). Then connect to a file-backed DuckDB database and create an example table to store inserted data. This table will track the name of the thread that completed the insert and automatically insert the timestamp when ... that insert occurred using the DEFAULT expression . import duckdb from threading import Thread, current_thread import random duckdb_co ... out parameters for an in-memory database # duckdb_con = duckdb.connect() duckdb_con.execute(""" CREATE OR REPLACE TABLE my_inserts ( thread_name VARCHAR, insert_time TIMESTAMP DEFAULT current_timestamp ) """) Reader and Writer Functions Next, define fu ...
https://man.mtool.work/duckdb/2.0/guides/python/multiple_threads.html
Merge Statement for SCD Type 2 7927
This is a practical, step-by-step guide to using DuckDB's MERGE statement (introduced in v1.4.0) to perform upserts and build Slowly Changing Dimension Type 2 (SCD Type 2) tables . Type 2 SCDs let you keep full historical versions of record ... key data, when it changed and for how long it was in a particular state. Why Use MERGE in DuckDB? Single SQL statement for INSERT , UPDATE , and soft DELETE (upsert and expire). Much cleaner and faster than equivalent Python/Pandas logic. Full history ... ess key + current flag) WHEN MATCHED Row exists in both → typically UPDATE (or DELETE) WHEN NOT MATCHED BY TARGET New row (insert) WHEN NOT MATCHED BY SOURCE Row disappeared → soft-delete/expire old version RETURNING merge_action Optional: shows what h ... appened to each row (INSERT/UPDATE/DELETE) Build an SCD Type 2 Dimension Table We'll track ducks and preserve history whenever their name, breed, or l ...
https://man.mtool.work/duckdb/2.0/guides/sql_features/merge.html
PREV 1 2 3 4 5 6 7 8 9 10 NEXT
DuckDB 2.0 Documentation / man.mtool.work