clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3798834 fiddles created (41833 in the last week).

CREATE TABLE foo (straw text);
 hidden batch(es)


-- standard SQL notation works, of course CREATE INDEX ON foo (CAST(straw AS int));
 hidden batch(es)


-- short notation with the cast operatror is disallowed CREATE INDEX ON foo (straw::int);
ERROR: syntax error at or near "::" LINE 2: CREATE INDEX ON foo (straw::int); ^
 hidden batch(es)


-- but it works with parentheses: CREATE INDEX ON foo ((straw::int));
 hidden batch(es)


-- note that either notation in a query qualifies for using the index with eithe notation SELECT * FROM foo WHERE straw::int = 123;
straw
 hidden batch(es)