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)

Last updated