Postgresql在mybatis中報(bào)錯(cuò):操作符不存在:character varying == unknown的問題
錯(cuò)誤: 操作符不存在: character varying == unknown , Hint: 沒有匹配指定名稱和參數(shù)類型的操作符. 您也許需要增加明確的類型轉(zhuǎn)換.
在Mybatis條件查詢時(shí),動(dòng)態(tài)SQL的一個(gè)錯(cuò)誤,sql寫的也不多,沒仔細(xì)看所以一直找不到錯(cuò)誤,網(wǎng)上也找不到類似的錯(cuò)誤,結(jié)果是低級(jí)錯(cuò)誤。。。
<div>
<form:select path="finished" class="col-xs-12 form-control m-b">
<form:option value="" label="請(qǐng)選擇"/>
<from:options items="${fns:getDictList('fin')}" itemLabel="label"
itemValue="value" htmlEscape="false"/>
</form:select>
</div>
下面的動(dòng)態(tài)sql查詢是根據(jù)前臺(tái)字典傳過來的值 0或1或'' ,來判斷d_sign的值進(jìn)行數(shù)據(jù)過濾查詢,默認(rèn)傳過來''(空字符串)則均不進(jìn)下面的判斷條件里,是0 或 1 才進(jìn)去。
① <if test="dSign!=null and dSign =='0'.toString()"> AND (b.d_sign is null or b.d_sign='') </if> ② <if test="dSign!=null and dSign =='1'.toString()"> AND (b.d_sign is not null AND b.d_sign!='') </if>
我把上面①里面的 b.d_sign='' 寫成了b.d_sign=='',從而報(bào)了上面的錯(cuò)誤。
另外把自己用到的一些postgresql中的sql語句做個(gè)整理:
我的postgresql數(shù)據(jù)庫版本
select version(); //查詢版本語句
PostgreSQL 9.5.22, compiled by Visual C++ build 1800, 64-bit
修改表名
alter table table_name rename to table_name2;
修改字段的默認(rèn)值
ALTER TABLE 表名 ALTER COLUMN 列名 SET DEFAULT 默認(rèn)值;
設(shè)置某個(gè)字段的值為null
正確示范:
update table_name set fin=null; //正常完成修改操作
錯(cuò)誤示范:
update table_name set fin is null; // 報(bào)語法錯(cuò)誤?。?!
修改表中值為null的數(shù)據(jù)
正確示范:
update table_name set fin='0' where fin is null ; //正常完成修改操作
錯(cuò)誤示范:
update table_name set fin='0' where fin = null ; //不報(bào)語法錯(cuò)誤,但修改條數(shù)是0,不起修改作用
修改字段的類型
alter table 表名 alter COLUMN 列名 type varchar(255) ;
添加字段
ALTER TABLE 表名 ADD 字段名 varchar(36);
其他測試:
//表中總共的記錄數(shù) select count(1) from table_name 32 select count(1) from table_name where d_sign is null 9 //32=9+23 select count(1) from table_name where d_sign is not null 23 //23=5+18 select count(1) from table_name where d_sign= '' 5 select count(1) from table_name where d_sign!='' 18 select count(1) from table_name where d_sign is null or d_sign='' 14 //32=14+18 select count(1) from table_name where d_sign is not null AND d_sign!='' 18
到此這篇關(guān)于Postgresql在mybatis中報(bào)錯(cuò): 操作符不存在: character varying == unknown的文章就介紹到這了,更多相關(guān)Postgresql報(bào)錯(cuò)操作符不存在內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
postgresql如何找到表中重復(fù)數(shù)據(jù)的行并刪除
這篇文章主要介紹了postgresql如何找到表中重復(fù)數(shù)據(jù)的行并刪除問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-05-05
使用navicat連接postgresql報(bào)錯(cuò)問題圖文解決辦法
我們?cè)谌粘i_發(fā)中有時(shí)候需要用navicate連接postgresql數(shù)據(jù)庫,有時(shí)候會(huì)連接不上數(shù)據(jù)庫,下面這篇文章主要給大家介紹了關(guān)于使用navicat連接postgresql報(bào)錯(cuò)問題圖文解決辦法,需要的朋友可以參考下2023-11-11
Postgresql 實(shí)現(xiàn)查詢一個(gè)表/所有表的所有列名
這篇文章主要介紹了Postgresql 實(shí)現(xiàn)查詢一個(gè)表/所有表的所有列名,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-12-12
PostgreSQL中實(shí)現(xiàn)數(shù)據(jù)實(shí)時(shí)監(jiān)控和預(yù)警的步驟詳解
在 PostgreSQL 中實(shí)現(xiàn)數(shù)據(jù)的實(shí)時(shí)監(jiān)控和預(yù)警是確保數(shù)據(jù)庫性能和數(shù)據(jù)完整性的關(guān)鍵任務(wù),以下將詳細(xì)討論如何實(shí)現(xiàn)此目標(biāo),并提供相應(yīng)的解決方案和具體示例,需要的朋友可以參考下2024-07-07
PostgreSQL設(shè)置時(shí)區(qū)、時(shí)間/日期函數(shù)匯總大全
PostgreSQL是一款簡介而又性能強(qiáng)大的數(shù)據(jù)庫應(yīng)用程序,其在日期時(shí)間數(shù)據(jù)方面所支持的功能也都非常給力,這篇文章主要給大家介紹了關(guān)于PostgreSQL設(shè)置時(shí)區(qū)、時(shí)間/日期函數(shù)的相關(guān)資料,需要的朋友可以參考下2023-09-09
PostgreSQL中的template0和template1庫使用實(shí)戰(zhàn)
這篇文章主要介紹了PostgreSQL中的template0和template1庫使用實(shí)戰(zhàn),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2021-01-01
postgresql 實(shí)現(xiàn)取出分組中最大的幾條數(shù)據(jù)
這篇文章主要介紹了postgresql 實(shí)現(xiàn)取出分組中最大的幾條數(shù)據(jù),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2021-01-01

