Loading topic
text, varchar(n) and char(n). They look similar, but they differ in length checks, padding and comparison rules. This chapter explains those differences so you can pick a type for each column and predict what string functions return.5 min readSELECT, WHERE and GROUP BY queries, know the common PostgreSQL data types, and can run queries in psql or another SQL client. It covers how NULL propagates through string operators and functions, which functions are exceptions, and how to convert betw5 min read|| operator, the concat function, and the concat_ws function. They give the same result when every input has a value, and different results when an input is NULL. This chapter assumes you can write basic SELECT queries, you know that NULL 4 min readSELECT and WHERE syntax, how PostgreSQL treats NULL, and the difference between text, varchar(n) and char(n). It also assumes your database uses the UTF8 encoding, which is the default on most installations. You can check with `SHOW server_encodi5 min readupper, lower and initcap. It assumes you can write basic SELECT and WHERE queries and know that NULL means "unknown". It also assumes you know the difference between text and varchar, which an earlier chapter cove5 min readSELECT and WHERE syntax, how NULL behaves in expressions, and how to run queries in psql or another client. Earlier chapters covered t5 min readstrpos, with position as its standard-SQL spelling. This chapter covers what they return, how that interacts with NULL, case and multibyte characters, and how to combine them with substring and left to cut strings5 min readtext, varchar and char(n) from the first chapter.6 min readreplace, translate and overlay. It assumes you can write basic SELECT, WHERE and UPDATE statements, and that you know NULL propagates through most string functions. Earlier chapters showed how to find text with strpos.5 min readSELECT queries with WHERE, and that you know PostgreSQL treats NULL as "unknown". Earlier chapters covered text columns, lower() and strpos(). Here you use pattern matching to answer questions like "which names start with Ph?" or "which names contain th5 min readSELECT, WHERE and GROUP BY queries, know that NULL means "unknown", and can run queries in psql or another client. Some examples use 5 min readSELECT and WHERE queries, know how LIKE works, and can run queries in psql or another client. You don't need to have used regular expressions in another language. The chapter covers how PostgreSQL's regex operators and functions behave, and where they5 min read|| and concat, and that you know how NULL behaves in string expressions. It covers format, which builds text from a template, and the quoting functions quote_ident, quote_literal and quote_nullable. Together they let you generate SQL 5 min readchar_length, lower, ORDER BY) and can run queries in psql. It covers two database settings that change string results without any change to your SQL: the encoding and the collation.6 min readEXPLAIN plan and know what a B-tree index is. It also assumes you have met lower(), LIKE, ILIKE and ~ in the earlier chapters. Here you will learn which index serves which string filter, and why a query often ignores an index you think should help.5 min read