Dynamic Table
Dynamic Table DDL commands are used to create, modify, query, and delete dynamic table objects that auto-incrementally refresh based on SQL queries.
This Chapter
Common Operations
Create a Dynamic Table
-- Basic dynamic table (refresh every 10 minutes)
CREATE OR REPLACE DYNAMIC TABLE public.dws_category_sales
REFRESH INTERVAL 10 MINUTE
VCLUSTER default
AS
SELECT p.category,
COUNT(*) AS order_cnt,
SUM(o.quantity) AS total_quantity
FROM public.orders o
JOIN public.products p ON o.product_id = p.product_id
GROUP BY p.category;
Modify Refresh Configuration
-- Change refresh interval
ALTER DYNAMIC TABLE public.dws_category_sales SET REFRESH INTERVAL 30 MINUTE;
-- Suspend automatic refresh
ALTER DYNAMIC TABLE public.dws_category_sales SUSPEND;
-- Resume automatic refresh
ALTER DYNAMIC TABLE public.dws_category_sales RESUME;
Manual Refresh
-- Trigger a refresh immediately
REFRESH DYNAMIC TABLE public.dws_category_sales;
View and Monitor
-- View all dynamic tables
SHOW DYNAMIC TABLES;
-- View dynamic table status and refresh configuration
DESC DYNAMIC TABLE public.dws_category_sales;
-- View refresh history (last 10 runs)
SHOW DYNAMIC TABLE REFRESH HISTORY WHERE name = 'dws_category_sales' LIMIT 10;
Delete and Restore
-- Delete dynamic table
DROP DYNAMIC TABLE IF EXISTS public.dws_category_sales;
-- Restore deleted dynamic table
UNDROP DYNAMIC TABLE public.dws_category_sales;