mysql/mariadb: JSON_KEYS(col) -> native, returns a JSON array of keys.
postgres/cockroachdb: ARRAY(SELECT jsonb_object_keys(col)) -> a SQL
text array of keys.
sqlite: (SELECT json_group_array(key) FROM json_each(col)) -> a JSON
array of keys, built from SQLite's own json_each table-valued function.
snowflake: OBJECT_KEYS(col) -> native, returns an ARRAY of keys.
clickhouse: JSONExtractKeys(col) -> native, returns an Array(String).
mssql: no native function returns a JSON/array value of keys inline;
OPENJSON requires a derived table, so the closest inline expression is
a scalar subquery producing a comma-separated string (NOT a JSON array):
(SELECT STRING_AGG([key], ',') FROM OPENJSON(col)).
oracle, redshift, db2: throw "not supported" - none of these dialects
expose a documented function/operator that enumerates JSON object keys
as a value usable inline in a SELECT list, so faking one with a fragile
workaround would be worse than a clear error.
Get the list of top-level keys of a JSON object.
JSON_KEYS(col)-> native, returns a JSON array of keys.ARRAY(SELECT jsonb_object_keys(col))-> a SQL text array of keys.(SELECT json_group_array(key) FROM json_each(col))-> a JSON array of keys, built from SQLite's ownjson_eachtable-valued function.OBJECT_KEYS(col)-> native, returns an ARRAY of keys.JSONExtractKeys(col)-> native, returns an Array(String).OPENJSONrequires a derived table, so the closest inline expression is a scalar subquery producing a comma-separated string (NOT a JSON array):(SELECT STRING_AGG([key], ',') FROM OPENJSON(col)).