MySQL Part 3
MySQL Part 3
Open Source
MySQL
It is a freely available open source RDBMS.
It can be downloaded from www.mysql.org
MySQL is created and supported by MySQL AB,
a company based in Sweden, now a subsidiary of
Sun Microsystems.
The chief inventor was Michael Widenius.
MySQL Database System
It is a combination of MySQL Server instance and
MySQL Database.
It operates using the client/ server architecture in
which the server runs on the machine containing the
database, and any number of clients can connect to
the server through a network.
The client connect to the server and issue queries
using the SQL (Structured Query Language).
The server listens to the client requests, accesses the
database contents and returns the result.
Key Features of MySQL
Most Popular
open source
Not Case- database Reliable
sensitive
MySQL High
Easy to
Performance
learn
Platform
Independent Scalable
SQL
SQL is the set of commands that is used to
work on all RDBMS.
SQL
Insert
Update
Delete
Select
TCL (Transaction Control Language)
Commands that allow managing and
controlling a transaction.
Commit
Rollback
Savepoint
Data Types
They are the means to identify the type of data
and associated operations for handling it.
Data
Types
Int/
Char Varchar Float Double Decimal Date Time
Integer
MySQL Commands
Creating a Database
SYNTAX
CREATE DATABASE databasename;
EXAMPLE
mysql> create database school;
To see the available databases
SYNTAX
show databases;
Using a Database
SYNTAX
use databasename;
EXAMPLE
mysql> use school;
Creating tables in MySQL
SYNTAX
CREATE TABLE tablename(
attributename1 datatype constraint,
attributename2 datatype constraint,
:
attributenameN datatype constraint);
Example:
create table student
(rollno integer,
name varchar(20),
class varchar(10),
marks decimal);
Example 1
Write SQL command to Create table transporter
create a table ‘Transporter’ ( OrderId integer,
with the following Drivername varchar(50),
structure:
Itemtransported varchar(50),
Traveldate date,
Destinationcity varchar(50));
Example 2
Write an SQL command to Create table products
create the table ( Product_id varchar(6),
“Products” with the Product_name varchar(25),
following structure
Company varchar(30),
Field Type Packing varchar(20),
Product_id Varchar(6)
Product_Name Varchar(25)
CP Integer,
Company Varchar(30) SP Integer,
Packing Varchar(20)
CP Integer Quantity Integer );
SP Integer
Quantity Integer