Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Abi.m - Day-03

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 17

SQL BLENDED

LEARNING

PRESENTED BY
ABI.M
III-YEAR BE(CSE)

Linkdin
https://www.linkedin.com/in/abi-m-4a1a92282
AGENDA

1. INTRODUCTION
2. INSTALLING MYSQL ON MAC
3. INSTALLING MYSQL ON WINDOWS
4. CREATING A DATABASE
5. INSERTING A ROW
6. UPDATE THE TABLE
INTRODUCTION

SQL stands for Structured Query Language.


 SQL is a computer language used to interact with
relational database systems.
SQL is a tool for organizing, managing, and
retrieving archived data from a computer database.
INSTALLING MYSQL ON WINDOWS

STEPS

Step 1
Download MySQL Installer: Go to the MySQL website and download the MySQL Installer
for Windows.

Step 2
Run Installer: Once downloaded, run the installer. You will be prompted to choose an
installation type. Select "Custom" to customize your installation options.

Step 3
Select Products: In the product selection screen, you can choose which MySQL products to
install. Typically, you'll want to install MySQL Server and MySQL Workbench for managing
your databases. You can also select additional tools or connectors if needed.
STEPS

Step 4
Configure MySQL Server: During the installation process, you'll be prompted to
configure MySQL Server. You'll need to set a root password and optionally configure
other settings like port number and service name.

Step 5
Complete Installation: Follow the remaining prompts to complete the installation
process. Once finished, you should have MySQL installed on your Windows system.
INSTALLING MYSQL ON MAC
STEPS
Step 1
Install Homebrew: If you haven't installed Homebrew already, open Terminal and paste
the following command, then press Enter
/bin/bash -c "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 2
Install MySQL with Homebrew: Once Homebrew is installed, you can install MySQL by
running the following command in your Terminal

brew install mysql


Step 3
Start MySQL: After the installation is complete, you can start the MySQL server by running
brew services start mysql
Step 4
Secure MySQL Installation: MySQL comes with a script to secure the installation. Run the
Run the following command and follow the prompts to set up security options
mysql_secure_installation
Step 5
Verify MySQL Installation: You can verify that MySQL is running by checking its status
brew services list
Step 6
Access MySQL: To access the MySQL command-line interface, open a new Terminal
window and type
mysql -u root –p
You'll be prompted to enter the password you set during the secure installation process.
CREATING THE DATABASE
 Create a new table in the database
 It specifies the structure of the table includes column name with Datatype

SYNTAX

CREATE table table_name


(
Column1 datatype (size),
column2 datatype (size),
.
.
columnN datatype(size)
);
EXAMPLE

CREATE TABLE Student (


StudentID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Email VARCHAR(100),
Phone VARCHAR(20)
);

OUTPUT

StudentID FirstName LastName Email Phone


SELECT STATEMENT
 The SELECT statement is used to select data from a database.
 The SELECT statement in SQL is used to fetch or retrieve data
from a database.
 It allows users to access the data and retrieve specific data
based on specific conditions.

SYNTAX

SELECT col1,col2,…...,coln FROM tablename;

SELECT * FROM tablename;


EXAMPLE

SELECT * FROM Student;

OUTPUT

StudentId FirstName LastName Email Phone


05 Nikil M nikil@gmail.com 9845689025
USING WHERE CONDITION
 WHERE keyword is used for fetching filtered data in a result set.
 It is used to fetch data according to particular criteria

SYNTAX
SELECT * FROM table_name WHERE column_name operator value;

EXAMPLE
SELECT * FROM Student
WHERE StudentID=05;

OUTPUT
StudentId FirstName LastName Email Phone
05 Nikil M nikil@gmail.com 9845689025
INSERTING SINGLE ROW
 Inserting a data in the Database
 The INSERT INTO statement in SQL is used to add new records to a table in a
database. It is a fundamental command for data insertion and is used to insert new
data into tables.

Only Values
specify only the value of data to be inserted in the database.

SYNTAX
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
EXAMPLE

INSERT INTO Student(StudentID,FirstName,LastName,Email,Phone)


VALUES (‘05’,’Nikil’,’M’,’nikil@gmail.com’,’9845689025’);

OUTPUT

StudentID FirstName LastName Email Phone


05 Nikil M nikil@gmail.com 9845689025
UPDATING A SINGLE ROW
 The UPDATE statement in SQL is used to update the data of an existing table in
the database.
 We can update single columns as well as multiple columns using the UPDATE
statement as per our requirement.

 In a very simple way, we can say that SQL commands(UPDATE and DELETE)
are used to change the data that is already in the database .

SYNTAX

UPDATE table_name
SET column1 = value1, column2 =value2,…
WHERE condition;
EXAMPLE

UPDATE Student
SET Address=50,kovilstreet,avadi
WHERE StudentID = 05;

OUTPUT

StudentID FirstName LastName Email Phone ADDRESS


05 Nikil M nikil@gmail.com 9845689025 50,kovilstreet,avadi

You might also like