Will clickhouse copy new data by using insert+select? - Stack Overflow

admin2025-04-20  5

Will ClickHouse copy data by insert into ... select which added when operation already in progress?

PS^ I know it has to do with the level of isolation, but there are a lot of unclear points for ClickHouse.

Will ClickHouse copy data by insert into ... select which added when operation already in progress?

PS^ I know it has to do with the level of isolation, but there are a lot of unclear points for ClickHouse.

Share Improve this question edited Jan 24 at 9:36 Hett asked Jan 24 at 8:39 HettHett 3,8412 gold badges39 silver badges56 bronze badges 3
  • 1 Clickhouse uses MVCC for concurrent transactions. So, you shouldn't see any data changes after your query start time. See Notes. – Mark Barinstein Commented Jan 24 at 11:31
  • @MarkBarinstein this page says that transactions is expreimental feature and should be enabled by allow_experimental_transactions, right? Thus by default transaction will not be used? – Hett Commented Jan 24 at 12:13
  • 1 Transactions are not needed to make SELECT see data at the moment of its start time only. Subsequent data changes to the underlying tables are not visible for this SELECT. – Mark Barinstein Commented Jan 24 at 14:03
Add a comment  | 

2 Answers 2

Reset to default 1

No, clickhouse will only copy data which is present at the start of the execution of the INSERT ... SELECT ... query.

Yes, ClickHouse supports copying new data from one table to another using the INSERT INTO ... SELECT syntax.

INSERT INTO target_table SELECT * FROM source_table WHERE condition;

Here's how you could write the SQL command:

INSERT INTO former_employees
SELECT * FROM employees
WHERE status = 'Inactive';

In this example:

  • former_employees is the target table where data will be inserted.
  • employees is the source table from where data is selected.
  • The WHERE clause filters out the employees whose status is 'Inactive'.
转载请注明原文地址:http://anycun.com/QandA/1745153155a90400.html