> This page location: String Functions > LTRIM
> Full Neon documentation index: https://neon.com/docs/llms.txt
> IMPORTANT: If this page contains inaccurate or outdated information, report it: POST to https://neon.com/api/docs-feedback with {"feedback": "describe the issue", "path": "/postgresql/string-functions/ltrim"}

# PostgreSQL LTRIM() Function

**Summary**: in this tutorial, you will learn how to use the PostgreSQL `LTRIM()` function to remove specified characters from the beginning of a string.

## Introduction to PostgreSQL LTRIM() function

The `LTRIM()` function allows you to remove specified characters from the beginning of a string.

Here's the syntax of the `LTRIM()` function:

```sql
LTRIM(string, character)
```

In this syntax:

- `string` is the input string that you want to remove characters.
- `character` specifies the characters you want to remove from the beginning of the `string`. The `character` parameter is optional. It defaults to space.

The `LTRIM()` function returns the string with all leading characters removed.

To remove both leading and trailing characters from a string, you use the [TRIM()](https://neon.com/postgresql/string-functions/postgresql-trim-function) function.

To remove the trailing characters from a string, you use the [RTRIM()](https://neon.com/postgresql/string-functions/postgresql-rtrim) function.

## PostgreSQL LTRIM() function examples

Let's explore some examples of using the `LTRIM()` function.

### 1) Basic PostgreSQL LTRIM() function example

The following example uses the `LTRIM()` function to remove the `#` from the beginning of the string `#postgres`:

```sql
SELECT LTRIM('#postgres', '#');
```

Output:

```text
  ltrim
----------
 postgres
(1 row)
```

### 2) Using the PostgreSQL LTRIM() function to remove leading spaces

The following example uses the `LTRIM()` function to remove all the spaces from the string `' PostgreSQL'`:

```sql
SELECT LTRIM('   PostgreSQL');
```

Output:

```text
   ltrim
------------
 PostgreSQL
(1 row)
```

Since the default of the second argument of the `LTRIM()` function is space, we don't need to specify it.

### 3) Using the LTRIM() function with table data example

First, [create a new table](../postgresql-tutorial/postgresql-create-table) called `articles` and [insert some rows](../postgresql-tutorial/postgresql-insert-multiple-rows) into it:

```sql
CREATE TABLE articles(
   id SERIAL PRIMARY KEY,
   title VARCHAR(255) NOT NULL
);

INSERT INTO articles(title)
VALUES
   ('   Mastering PostgreSQL string functions'),
   (' PostgreSQL LTRIM() function')
RETURNING *;
```

Output:

```text
 id |                  title
----+------------------------------------------
  1 |    Mastering PostgreSQL string functions
  2 |  PostgreSQL LTRIM() function
(2 rows)
```

Second, [update](../postgresql-tutorial/postgresql-update) the titles by removing the leading spaces using the `LTRIM()` function:

```sql
UPDATE articles
SET title = LTRIM(title);
```

Output:

```sql
UPDATE 2
```

The output indicates that two rows were updated.

Third, verify the updates:

```sql
SELECT * FROM articles;
```

Output:

```text
 id |                 title
----+---------------------------------------
  1 | Mastering PostgreSQL string functions
  2 | PostgreSQL LTRIM() function
(2 rows)
```

## Summary

- Use `LTRIM()` function to remove all specified characters from the beginning of a string.

---

## Related docs (String Functions)

- [ASCII](https://neon.com/postgresql/string-functions/ascii)
- [CHR](https://neon.com/postgresql/string-functions/chr)
- [CONCAT](https://neon.com/postgresql/string-functions/concat-function)
- [CONCAT_WS](https://neon.com/postgresql/string-functions/concat_ws)
- [FORMAT](https://neon.com/postgresql/string-functions/format)
- [INITCAP](https://neon.com/postgresql/string-functions/initcap)
- [LEFT](https://neon.com/postgresql/string-functions/left)
- [LENGTH](https://neon.com/postgresql/string-functions/length-function)
- [LOWER](https://neon.com/postgresql/string-functions/lower)
- [LPAD](https://neon.com/postgresql/string-functions/lpad)
- [MD5](https://neon.com/postgresql/string-functions/md5)
- [POSITION](https://neon.com/postgresql/string-functions/position)
- [REGEXP_MATCHES](https://neon.com/postgresql/string-functions/regexp_matches)
- [REGEXP_REPLACE](https://neon.com/postgresql/string-functions/regexp_replace)
- [REPEAT](https://neon.com/postgresql/string-functions/repeat)
- [REVERSE](https://neon.com/postgresql/string-functions/reverse)
- [REPLACE](https://neon.com/postgresql/string-functions/replace)
- [RIGHT](https://neon.com/postgresql/string-functions/right)
- [RPAD](https://neon.com/postgresql/string-functions/rpad)
- [RTRIM](https://neon.com/postgresql/string-functions/rtrim)
- [SPLIT_PART](https://neon.com/postgresql/string-functions/split_part)
- [SUBSTRING](https://neon.com/postgresql/string-functions/substring)
- [TO_CHAR](https://neon.com/postgresql/string-functions/to_char)
- [TO_NUMBER](https://neon.com/postgresql/string-functions/to_number)
- [TRANSLATE](https://neon.com/postgresql/string-functions/translate)
- [TRIM](https://neon.com/postgresql/string-functions/trim-function)
- [UPPER](https://neon.com/postgresql/string-functions/upper)
