COLLATE lets you dictate how strings are compared and ordered at query time or column definition time. A collation defines character set, case sensitivity (CS/CI), accent sensitivity (AS/AI), and linguistic ordering rules. When used in a SELECT, ORDER BY, or WHERE clause, COLLATE applies only to that expression. When used in CREATE/ALTER TABLE it becomes the permanent collation for the column, affecting all future queries unless another COLLATE is supplied. Different databases ship with dozens of collations such as 'en_US', 'utf8_general_ci', or 'Latin1_General_CS_AS'. Mixing collations in the same expression without explicitly reconciling them raises an error. Performance is similar to default comparisons, but using binary collations can speed up large sorts at the cost of human-friendly ordering.
• expression
(string) - The string literal, column, or concatenated expression to which the collation is applied.• collation_name
(string) - The target collation such as 'utf8mb4_unicode_ci' or 'French_CI_AI'.ORDER BY, CHARACTER SET, NLS_SORT, NLS_COMP, CASE SENSITIVITY
SQL:1999 standard (vendor-specific support appeared earlier in SQL Server 7.0 and MySQL 4.1)
A collation is a set of rules that dictates how characters are compared and sorted, including case and accent handling.
Use a catalog query: - PostgreSQL: SELECT * FROM pg_collation;- MySQL: SHOW COLLATION;- SQL Server: SELECT name FROM sys.fn_helpcollations();
It depends on the collation chosen. Many names ending in _ci are case-insensitive, while _cs signifies case-sensitive.
Yes. Defining a column with a specific collation means any index on that column follows the same comparison rules, enabling efficient locale-aware lookups.