Skip to content

Instantly share code, notes, and snippets.

@chrisa
Created July 25, 2013 13:43
Show Gist options
  • Select an option

  • Save chrisa/6079753 to your computer and use it in GitHub Desktop.

Select an option

Save chrisa/6079753 to your computer and use it in GitHub Desktop.
postgres=# create table foo (a char(10), b varchar(10));
CREATE TABLE
postgres=# insert into foo(a) values ('foo ');
INSERT 0 1
postgres=# select * from foo where a = 'foo';
a | b
------------+---
foo |
(1 row)
postgres=# select * from foo where a = 'foo ';
a | b
------------+---
foo |
(1 row)
postgres=# select * from foo where a = 'foo ';
a | b
------------+---
foo |
(1 row)
postgres=# select * from foo where a = 'foo ';
a | b
------------+---
foo |
(1 row)
postgres=# select * from foo where a = 'foo ';
a | b
------------+---
foo |
(1 row)
postgres=# insert into foo(b) values('foo ');
INSERT 0 1
postgres=# select * from foo where b = 'foo';
a | b
---+---
(0 rows)
postgres=# select * from foo where b = 'foo ';
a | b
---+-------
| foo
(1 row)
postgres=# insert into foo(b) values('foo jkjjjjjjjjjjjjjjjjjjjjjjjjj');
ERROR: value too long for type character varying(10)
postgres=# insert into foo(b) values('foo a');
ERROR: value too long for type character varying(10)
postgres=# insert into foo(b) values('foo ');
INSERT 0 1
# wait, what?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment