0% found this document useful (0 votes)
10 views3 pages

SQL Basics for Database Beginners

The document provides an overview of SQL for creating and manipulating databases, including syntax for creating tables and altering them. It includes examples for creating an 'employee' table, adding and dropping columns, and establishing relationships between tables such as 'manager' and 'project'. Additionally, it illustrates how to handle one-to-many and many-to-many relationships using foreign keys.

Uploaded by

Ahmad Hazem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

SQL Basics for Database Beginners

The document provides an overview of SQL for creating and manipulating databases, including syntax for creating tables and altering them. It includes examples for creating an 'employee' table, adding and dropping columns, and establishing relationships between tables such as 'manager' and 'project'. Additionally, it illustrates how to handle one-to-many and many-to-many relationships using foreign keys.

Uploaded by

Ahmad Hazem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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