In PostgreSQL, when querying a table with a lax and a lowercase mixed name, a problem often encounters a problem. When the name of the name is used, the combination of a small and small, may cause the error message, indicating that the column does not exist.
Understand the sensitivity of the postgresql identifier
PostgreSQL is regarded as a identifier. By default, the identifier does not distinguish the case. This means that if the name statement is "FIRSTNAME", "FirstName" or "FirstName", PostgreSQL will identify them as the same column. However, there are exceptions to this rule.
Double quotation marks: keep the sensitivity of the case
When the identifier is included in the dual quotes (for example, "firstName"), PostgreSQL is regarded as a distinction. This will retain any capital letter or grammar conflict, otherwise these conflicts may be standardized into a lowercase. For example, a column named "1st_name" only matches query using the same beam. Division of writing inquiries
To query a table with a small and lowercase name, you need to include the list name with dual quotes. For example, to select the "firstName" column equal to the "xyz" line, the inquiry should be:
In this example, the dual quotes ensure that the postgreSQL search is called "firstName" column, regardless of the appliances used in the definition.
The best practice named the identifier
SELECT * FROM persons WHERE "firstName" = 'xyz';
In order to avoid the sensitivity of the case, it is recommended to use a lowercase and legal name for the list of and other database standards. This eliminates the demand for dual quotes and simplifies the inquiries. By complying with this agreement, developers can ensure naming consistency and prevent accidental query errors.
The above is the detailed content of Is PostgreSQL's Column Name Case-Sensitivity Dependent on Quotation Marks?. For more information, please follow other related articles on the PHP Chinese website!