---
name: "tdb_store"
section: "3"
platform: "linux"
package: "libtdb-dev"
version: "2:1.4.13+samba4.22.11+dfsg-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/tdb_store"
---

# tdb\_store(3)

store a record in a tdb database.

## NAME

tdb\_store - store a record in a tdb database.

## SYNOPSIS

```
#include <tdb.h>

int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA record, int flag);

```

## DESCRIPTION

Store a lump of data pointed to by *record* in the *tdb* database under the index pointed to by *key.* The TDB\_DATA structure used by both *key* and *record* is defined as:

```
typedef struct {
	char *dptr;
	size_t dsize;
} TDB_DATA;
```

The *flag* determines the way that tdb\_store behaves and can be any one of the following values.

- **TDB\_REPLACE**

  Insert a record creating a new one or overwriting an existing one.

- **TDB\_INSERT**

  Insert a new entry but refuse to overwrite an existing entry.

- **TDB\_MODIFY**

  Replace an existing record with a new one. This will fail if, a record does not already exist.

## RETURN VALUE

A return value of 0 indicates success and -1 indicates failure.

## AUTHORS

Software: Andrew Tridgell \<tridge@linuxcare.com\> and Luke Kenneth Casson Leighton Man page: Ben Woodard \<ben@valinux.com\>

## SEE ALSO

[**gdbm**(3)](/gdbm/3.md), **[tdb(3)](/tdb/3.md)**
