Postgresql中DDL的雙引號問題
Position: 57
at org.jooq.impl.Tools.translate(Tools.java:1941)
at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:659)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:362)
at org.jooq.impl.AbstractDelegatingQuery.execute(AbstractDelegatingQuery.java:135)
... ...
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.postgresql.util.PSQLException: ERROR: column "billId" of relation "tb_purchase" does not exist
Position: 57
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2310)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2023)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:217)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:421)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:166)
at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:159)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:989)
at org.jooq.tools.jdbc.DefaultPreparedStatement.execute(DefaultPreparedStatement.java:194)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:430)
at org.jooq.impl.AbstractDMLQuery.execute(AbstractDMLQuery.java:334)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:348)
... 101 more
檢視資料庫,這個表確實有這個欄位,匯出ddl,發現表名、欄位名都有雙引號,去掉雙引號重新建立表,還是報錯,最後發現是由於雙引號裡面的字元區分大小寫。
PostgreSQL is following the SQL standard and in that case that means that identifiers (table names, column names, etc) are forced to lowercase, except when they are quoted. So when you create a table like this:
CREATE TABLE APP_USER ...
you actually get a table app_user. You apparently did:
CREATE TABLE "APP_USER" ...
and then you get a table "APP_USER".
In Spring, you specify a regular string for the table name, in capital letters, but that gets spliced into a query to the PostgreSQL server without quotes. You can check this by reading the PostgreSQL log files: it should show the query that Spring generated followed by the error at the top of your message.
Since you have very little control over how Spring constructs queries from entities, you are better off using SQL-standard lower-case identifiers
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9399028/viewspace-2132619/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle中的 單引號 和 雙引號Oracle
- Linux Shell 中的反引號,單引號,雙引號Linux
- Oracle中單引號和雙引號的區別Oracle
- PHP中單引號和雙引號的區別PHP
- linux bash中的引號:單雙引號、反撇號Linux
- shell 指令碼中雙引號、單引號、反引號的區別指令碼
- Python中 單引號,雙引號和三引號的區別Python
- python中單引號,雙引號,多引號區別Python
- Oracle中單引號與雙引號的區別分析Oracle
- shell中單引號、雙引號、反引號、反斜槓的區別
- PHP中對單引號和雙引號的區別(好文)PHP
- Golang的單引號、雙引號與反引號Golang
- ORACLE 單引號 雙引號Oracle
- JS中缺少分號可能引發的問題JS
- js中關於單引號和雙引號的一點用法JS
- asp.net中關於雙引號和單引號的用法ASP.NET
- latex的雙引號 ``'
- oracle 裡的單引號與雙引號Oracle
- linux 單引號,雙引號,反引號Linux
- smarty 雙引號中嵌入變數的方法變數
- HTML 單引號與雙引號HTML
- 字串中包含單引號和雙引號怎麼處理字串
- shell中定義變數用雙引號和單引號以及不用引號的區別變數
- Jquery單引號和雙引號的使用注意jQuery
- SQL語句中的單引號與雙引號SQL
- 關於 json 單引號和雙引號區別--請使用雙引號JSON
- grep 後加單引號、雙引號和不加引號的區別
- MySQL 中如何定位 DDL 被阻塞的問題MySql
- Linux中單引號和雙引號的使用方法及注意事項!Linux
- oracle 中使用單引號(')和雙引號(")Oracle
- python中怎麼輸出雙引號Python
- javascript的雙引號和單引號的用法和區別JavaScript
- MySQL 5.6中如何定位DDL被阻塞的問題MySql
- 【C進階】14、單引號和雙引號
- 瞭解 Oracle 中單引號與雙引號的用法,一篇文章教會你!Oracle
- 在ORACLE SQL語句中,單引號和雙引號的使用OracleSQL
- PHP雙引號的小隱患PHP
- 向SQLServer插入單引號問題SQLServer