Practical Sheet 01
Practical Sheet 01
Practical Sheet 01
Introduction
● My SQL is the database management system we are working with.
● It is an Open Source Database Management System available online to be downloaded
freely.
● MySQL Data Types help you to properly define fields in a table, for overall optimization of
your database.
● MySQL uses many different data types broken into three categories. They are as
follows.
A) String Data Types
1. Create Database
Here is a generic SQL syntax to create a MySQL Database. The name of the database we are
creating is EMPLOYEE.
The USE statement tells MySQL to use the named database as the default (current) database
for subsequent statements.
USE COMPANY;
3. Create Tables
To begin with, the table creation command requires the following details.
Minit CHAR,
Lname VARCHAR(15),
Ssn CHAR(9),
Bdate DATE,
Address VARCHAR(15),
Sex CHAR,
Salary DECIMAL(10,2),
Super_ssn CHAR(9),
Dno INT);
● We use the DESCRIBE command to show the structure of our table, such as column
names, constraints etc.
● The DESC command is a short form of the DESCRIBE command.
DESCRIBE employee;
DESC employee;
Drop columns
Method 1
VALUES
VALUES
7. Update Tables
There are several ways in which you can update a table.
UPDATE EMPLOYEE
UPDATE EMPLOYEE
WHERE Dno=5;
UPDATE EMPLOYEE
WHERE Super_ssn='88866555';
Be careful when updating records. If you omit the WHERE clause, ALL records will be updated!
8. Delete
You can delete data in tables in the following methods.
Drop a Database