> For the complete documentation index, see [llms.txt](https://vikram-bajaj.gitbook.io/cs-gy-6083-principles-of-database-systems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vikram-bajaj.gitbook.io/cs-gy-6083-principles-of-database-systems/sql/ddl-commands/creating-a-table.md).

# Creating a Table

```
create table r (A1 D1, A2 D2, ..., An Dn, IC1, IC2, ..., ICk)
```

* r is the name of the relation/table
* A1, A2, ..., An are attributes
* D1, D2, ..., Dn are the data types of values in the domains of the corresponding attributes
* IC1, IC2, ..., ICk are integrity constraints

Ex. the following creates a table for the instructor relation with primary and foreign key constraints

```
create table instructor (ID char(5), name varchar(20) not null, dept_name varchar(20), salary numeric(8, 2), 
                         primary key (ID), foreign key (dept_name) references department)
```

## Inserting Values

```
insert into r values (V1, V2, ..., Vn)
```
