Execute and manage Common Table Expressions (CTEs) with ease in DataGrip and IntelliJ-based IDEs.
- Detects all CTEs in your SQL
WITHclause automatically - Interactive popup chooser to select which CTE(s) you want to execute or copy
- Visual highlighting of selected CTE(s) inside the editor for better clarity
- Smart execution - executes the chosen SQL query in the database console
- Copy to clipboard - quickly copy any CTE query for use elsewhere
- Execute from anywhere - not just CTEs! Works with any subselect in your SQL
- Automatic dependency resolution - automatically includes all required CTEs
- Smart detection - finds dependencies in CTEs, subqueries, and final SELECT statements
- Interactive selection - choose exactly where to start execution from
- Keyboard shortcuts for lightning-fast workflow
- Minimal UI - stays out of your way
- Automatic cleanup - inserted SQL is removed after execution
- Lightweight - no performance impact
- Open a SQL file containing CTEs (WITH clauses)
- Place the caret anywhere inside or near a CTE
- Invoke Run CT-Query (shortcut:
Ctrl+#thenSpace) - Select the desired CTE from the popup
- The plugin highlights the relevant SQL and executes it in the console
- The inserted SQL is automatically cleaned up after execution
- Place your caret anywhere in your SQL - inside a CTE, subquery, or main SELECT
- Invoke Execute from Here (shortcut:
Ctrl+#thenEnter) - The plugin detects all dependencies and shows execution options
- Select where to execute from
- All required CTEs are automatically included
- Place the caret in a CTE
- Invoke Copy CT-Query SQL (shortcut:
Ctrl+#thenC) - The SQL is copied to your clipboard
- Place the caret in a CTE
- Invoke Edit and Run SQL (shortcut:
Ctrl+#thenW) - Modify the query (e.g., add WHERE clauses)
- The modified SQL is ready to execute
WITH
sales AS (SELECT * FROM orders WHERE year = 2024),
customers AS (SELECT * FROM users WHERE active = true)
SELECT * FROM sales
JOIN customers ON sales.user_id = customers.id;- Place caret in
salesCTE - Press
Ctrl+#→Space - Select "sales" from popup
- Executes:
WITH sales AS (...) SELECT * FROM sales
WITH
sales AS (SELECT * FROM orders WHERE year = 2024),
revenue AS (
SELECT
product_id,
SUM(amount) as total
FROM sales -- Place caret here
GROUP BY product_id
)
SELECT * FROM revenue WHERE total > 1000;- Place caret in the subquery inside
revenueCTE - Press
Ctrl+#→Enter - Plugin detects that
salesCTE is needed - Executes the subquery with all dependencies automatically included!
WITH
base AS (SELECT * FROM data),
filtered AS (SELECT * FROM base WHERE active = true),
aggregated AS (SELECT category, COUNT(*) FROM filtered GROUP BY category)
SELECT * FROM aggregated ORDER BY count DESC;- Place caret anywhere in
aggregated - Press
Ctrl+#→Enter - Automatically includes
baseandfilteredCTEs (all dependencies) - Clean, dependency-aware execution!
- Open IntelliJ IDEA / DataGrip
- Go to Settings → Plugins → Marketplace
- Search for "cteXecutor"
- Click Install
- Restart your IDE
Found a bug or have a feature request? Please open an issue on GitHub!
If you find this plugin helpful, please:
- ⭐ Star the repository
- 📝 Leave a review on the JetBrains Marketplace
- 🐛 Report bugs to help improve the plugin
- 💡 Share your ideas for new features
Made with ❤️ for SQL developers who work with CTEs