Home >Database >Mysql Tutorial >How Does PostgreSQL Handle Case Sensitivity in Column Names?
PostgreSQL database The sensitivity processing method of the column name depends on whether the name is included in the dual quotation number. The columns included in the dual quotation number are sensitive, and the column names that are not used in the dual quotation number are not sensitive (it will be converted to a lowercase). This means that "first_name" and "first_name" are two different columns, while "FirstName" and "FirstName" represent the same column (both converted into a lowercase).
In the sample query, because the dual quotation number is not used to include "first_name", it will be converted into a lowercase "firstName", and there is no name in the database, which causes errors.
Solution:
Use dual quotes:
In the query, use the dual quotes to include the name to maintain the sensitivity of the case:<code class="language-sql">SELECT * FROM persons WHERE "first_Name" = 'xyz';</code>Inquiry the actual appliances of the column name, and use in the query:
pg_class
, including the name variables of the case information. <code class="language-sql">SELECT * FROM persons WHERE column_name = 'first_Name';</code>It is recommended to use a full -handed naming naming specification without double quotation marks to avoid lowercase -related issues and ensure the consistency of the query.
The above is the detailed content of How Does PostgreSQL Handle Case Sensitivity in Column Names?. For more information, please follow other related articles on the PHP Chinese website!