Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

SQL Structured Query Language

To Access and manipulate Data base

Create table

Create table table_Name (


Column1 datatype,
Clo2 datatype,
…..
Col datatype
);
Data type :
Text, int ,date,varchar(255),…

CREATE TABLE employee (


EmpID int primary key,
LastName varchar(255),
FirstName varchar(255),
Age int ,
Email varchar(255),
Address varchar(255),
City varchar(255)
);

2) Add Bdate column to employee

Alter table employee


Add Bdate date;
3) alter table_ Drop column
Alter table employee
Drop column City ;

4) alter table – alter /modify col


Alter table employee
Alter column age date;
Relationship
1 to many
Employee Manager
Create table manager(
ManID int primary key,
Location text ,
Mname text,
EMPID int,
Foreign key (EMPID) references employee(EmpID));
Many – many
Employee Project
Create table Project (
Pno int primary key ,
PName text
);

Create table join(


EmpID int,
Foreign key (EmpID)references employee(EmpID),
PNO int ,
Foreign key (PNO)references Project (Pno)
);

You might also like