# Create Table Adds A Data Type

Each time you create a table in PostgreSQL, a new data type represented by that table is created and added to the `pg_type` table. According to the Postgres docs:

> CREATE TABLE also automatically creates a data type that represents the composite type corresponding to one row of the table. Therefore, tables cannot have the same name as any existing data type in the same schema.

For instance, if you create a `users` table like so:

```sql
create table users (
  id serial primary key,
  first_name varchar not null,
  last_name varchar not null
);
```

then the `pg_type` will now contain an entry with a `typname` of `users`.

```sql
select * from pg_type where typname = 'users';
-[ RECORD 1 ]--+------------
typname        | users
typnamespace   | 2200
typowner       | 16384
...
```

h/t Bruce Momjian


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ploegert.gitbook.io/til/programmy/linux/is-app-installed/table-operations/create-table-adds-a-data-type.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
