Skip to content

Instantly share code, notes, and snippets.

@redsquare
Last active March 14, 2024 16:11
Show Gist options
  • Save redsquare/b7ff192ef0b89e52fd6414b350b7b963 to your computer and use it in GitHub Desktop.
Save redsquare/b7ff192ef0b89e52fd6414b350b7b963 to your computer and use it in GitHub Desktop.
Dump Clickhouse Table Schemas
#dump table ddl's
clickhouse-client --host your_clickhouse_host -q "SHOW TABLES FROM db_name" | while read -r table_name; do
clickhouse-client --host your_clickhouse_host -q "SHOW CREATE TABLE db_name.\`$table_name\`" >> db_structure.sql
done
#restore
clickhouse-client --host target_clickhouse_host < db_structure.sql
#also in /var/lib/clickhouse/metadata/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment