Sybase HG Index Generator (VS Code Extension)
Generate Sybase ASE CREATE HG INDEX statements from a SQL query. This extension now includes a built-in TypeScript implementation and does not require Python.
Features
- Command: "Sybase: Generate HG INDEX from SQL"
- Works on selected text or the entire active document
- Opens results in a new SQL document
Requirements
- VS Code 1.93.0 or later
- No external runtime required
Extension Settings
- No settings are required for basic usage.
Usage
- Open a SQL file containing a
SELECT ... INTO
or INSERT INTO ... SELECT ...
query.
- Run the command: "Sybase: Generate HG INDEX from SQL" (Command Palette).
- A new editor tab opens with the generated index statements.
Examples
Try these sample queries (also available in extension_test.sql
). Select a query and run the command.
Basic: SELECT ... INTO
SELECT
a.user_id AS uid,
a.created_at,
b.amount,
a.status
INTO result_basic
FROM dbo.activity a
LEFT JOIN payments b ON b.user_id = a.user_id;
INSERT INTO SELECT
INSERT INTO agg_sales (user_id, total)
SELECT u.id AS user_id, SUM(o.amount) AS total
FROM users u
JOIN orders o ON o.user_id = u.id
GROUP BY u.id;
WITH chain + SELECT ... INTO
WITH
t1 AS (SELECT id, val FROM src1),
t2 AS (SELECT id, SUM(v) AS s FROM src2 GROUP BY id),
t3 AS (
SELECT t1.id, t1.val, t2.s FROM t1 JOIN t2 ON t1.id = t2.id
)
SELECT
t3.id,
t3.val,
t3.s AS sum_v
INTO out_cte1
FROM t3;
Recursive CTE-like + SELECT ... INTO
WITH r AS (
SELECT id, parent_id, name FROM nodes WHERE parent_id IS NULL
UNION ALL
SELECT n.id, n.parent_id, n.name FROM nodes n JOIN r ON n.parent_id = r.id
)
SELECT
r.id,
r.parent_id AS pid,
r.name
INTO tree_flat
FROM r;
Complex subqueries (EXISTS/Scalar) + SELECT ... INTO
WITH u AS (SELECT id, status FROM users)
SELECT
u.id,
(SELECT COUNT(*) FROM orders o WHERE o.user_id = u.id AND EXISTS (
SELECT 1 FROM flags f WHERE f.user_id = u.id
)) AS order_cnt,
CASE WHEN EXISTS(SELECT 1 FROM vip v WHERE v.user_id=u.id) THEN 1 ELSE 0 END AS is_vip
INTO user_enriched
FROM u;
Notes:
- Columns without aliases in complex expressions (e.g.,
SUM(s.v)
without AS ...
) may be ignored by the generator.
- Wildcards (
*
) are skipped for column-based index inference.
Known Issues
- Warnings and informational messages from the built-in generator are shown in the output channel.
Release Notes
0.1.0
- Built-in TypeScript generator. Python no longer required.
- Removed deprecated settings (
pythonPath
, scriptPath
).
0.0.1
License
MIT