Table name, field name capitalization problem in "Goto" PostgreSQL

Source: Internet
Author: User
Tags goto lowercase postgresql

When learning hibernate, the database uses PostgreSQL, the first lesson is thrown wrong, user entity mapping is not alive or alive cannot export the table. Always prompt this sentence:

Error:syntax ERROR at or near "User".

Later found that if the table name is set to t_user such a line, not PostgreSQL can not be capitalized? Try T_user again, no error, to the database to see, eh? or t_user!? uppercase automatically becomes lowercase. PostgreSQL does not recognize the case? Creating a user table with the Pgadmin graphical interface is no problem at all. After experimenting with the fields in the table, I found that it was also the problem, always prompting Error:syntax error at or near "..."

To look at Pgadmin's SQL window suddenly found ( many times careful observation is really important AH ), there are uppercase places are added double quotation marks


Oh, suddenly enlightened, not do not recognize the case, the mystery of the original in double quotation marks.

First use the SQL statement to try to establish a name is a capital letter table, remember the table name plus double quotation marks, run error-free, success!
Hibernate example has two solutions, one, is the table name in lowercase, the other is uppercase double quotation marks, of course, this time you will ask, both double quotation marks do not ah, with the escape symbol chant.


In the JPA example:





Summary:

    1. PostgreSQL is case-sensitive for table names and field names. The graphical interface can be created normally. Use the SQL statement with double quotes, if the JDBC query, etc., remember to use the escape symbol.
    2. PostgreSQL is not sensitive to capitalization in SQL statements

Select ID from t_user and select ID from T_user


Will query the ID field from the T_user table. If you want to query the fields in uppercase letters, double quotation marks are also added: select "ID" from T_user

Table name, field name capitalization problem in "Goto" PostgreSQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.