sqlcastingansi-sql

SQL cast target types: standardized?


SQL function

cast(expression as type):

It is ANSI standard. Is the type standardized? what types are allowed? Are they different from database to database?

Looked at the MySQL and others. MySQL has signed/unsigned, others has INT.


Solution

  • CAST() is ANSI standard. Off the top of my head, ANSI data types are things like:

    MySQL changes the syntax a bit. So, UNSIGNED and SIGNED are used instead of INT. And CHAR is used for all the character types. Other databases have their own modification for CAST(). For instance Google BigQuery uses string instead of the character types.