Câu hỏi phỏng vấn SQL
Câu hỏi

What is Collation?

Câu trả lời

Collation in the context of databases refers to a set of rules that determine how data is sorted and compared. These rules affect the way text values are stored, retrieved, and compared within the database. Collation is particularly important for handling different languages, scripts, and cultural conventions, as it dictates how characters are treated in terms of case sensitivity, accent sensitivity, and other linguistic features.

Key Aspects of Collation

  1. Sorting and Comparison Rules:

    • Collation defines how characters are ordered and compared. For example, it determines whether uppercase and lowercase letters are treated as equivalent or distinct, and how accented characters are handled[1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17].
  2. Levels of Collation:

    • Server-Level: The default collation for all system databases and any new user databases created on the server. It is set during the installation of the database server and can be complex to change later[2][3][4][5][6][7][10][12][17].
    • Database-Level: The collation used for all metadata within the database, including default settings for string columns, temporary objects, and variable names. It can be specified during database creation or altered later[2][3][4][5][6][7][10][12][17].
    • Column-Level: Specific collations can be set for individual columns within a table, overriding the database-level collation. This is useful for handling data that requires different sorting and comparison rules within the same database[2][3][4][5][6][7][10][12][17].
    • Expression-Level: Collation can be specified for individual expressions within a query, affecting how the results are sorted and compared[2][3][4][5][6][7][10][12][17].
  3. Collation Options:

    • Case Sensitivity: Determines whether uppercase and lowercase letters are treated as distinct (case-sensitive) or equivalent (case-insensitive)[2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17].
    • Accent Sensitivity: Determines whether accented characters are treated as distinct from their unaccented counterparts[2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17].
    • Kana Sensitivity: Relevant for Japanese characters, distinguishing between Hiragana and Katakana[2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17].
    • Width Sensitivity: Distinguishes between single-byte and double-byte characters[2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17].
    • Variation Selector Sensitivity: Used for distinguishing between ideographic variation selectors in certain languages like Japanese[2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17].

Practical Examples

  • Setting Collation: When creating a database or a table, you can specify the collation using the `COLLAT...
middle

middle

Gợi ý câu hỏi phỏng vấn

middle

What’s the difference between Azure SQL Database and Azure SQL Managed Instance?

middle

What is the difference between WHERE clause and HAVING clause?

middle

What is the difference between INNER JOIN , OUTER JOIN , FULL OUTER JOIN ?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào