---
title: "char类型补空格引发的案子"
author: "BenjaminYu"
date: "2013-06-17T10:24:14Z"
tags: []
categories: ["数据库"]
slug: "char"
draft: false
lastmod: "2013-06-17T10:24:14Z"
id: 1887840
url: "https://benjaminyu.iteye.com/blog/1887840"
---

不多说，都懂的：

```sql
create table test(
 col_char char(4)
);
insert into test values('a');
insert into test select 'a   'from dual;
insert into test values ('a000');
insert into test values('abc');
select col_char||'''' from test;
select replace(col_char,' ', '0') from test;
select * from test where col_char='a   ';
drop table test;
```