SlideShare a Scribd company logo
Laboratory Activity 1
                                     MySQL Basics
Objectives
At the end of the activity, student is expected to perform the following:

          Run MySQL command line
          Display available databases
          Create database and tables
          Alter table and set up primary key
          Insert, update and delete tables

Run MySQL Command Line Prompt
We run MySQL prompt, click Start | Programs | MySQL | MySQL Server 5.1 | MySQL
Command Line Client. See Figure 1. If you are prompted with a password, type the
password that you have assigned during running of MySQL Server Instance Config Wizard
or simply hit enter from keyboard.




                     Figure 1. Launching of Command Prompt Window


Page 1 of 7                                   http://ThrivingAndLiving.blogspot.com
Figure 2 shows the mysql command prompt line . You are now on MySQL Server
environment.




                            Figure 2. MySQL command prompt

Display Available Databases

MySQL comes with default databases upon installation. These are information_schema,
mysql and test. Mysql and information_schema databases are special databases where
MySql server stores various access permissions. Test database is used for various testing
features and sample databases.

       To display all the available databases on the server we type:

              SHOW DATABASES;

       Please take note that all commands should be terminated with semicolon to signal
MySQL that a command is completed and ready for execution. Figure 3 should show the
output of the command.




                     Figure 3. Databases available currently at server


Page 2 of 7                                  http://ThrivingAndLiving.blogspot.com
Create Database
We will now create our own (new) database. Let us say that the name of our database is
my_store. Command syntax for creating database is CREATE DATABASE <database
name>. Figure 4 displays the creation of my_store database after issuing the SHOW
DATABASES command.




                          Figure 4. my_store database is created

Create Table within the Database
Database consists of table/s where we store rows and columns. Creating a database does not
mean you open it automatically. USE <database name> is the syntax in opening a database.
In order to open my_store database we issue:

       USE my_store;

       We will create now a table products to hold all products data within the database.
Our products table consists of attributes/fieldnames vital in identifying description about a
product. Syntax in creating a table has this format:

       CREATE TABLE <table name> ( <fieldname1> DATA TYPE,
                                   <fieldname2> DATA TYPE…
                                   <fieldnameN> DATA TYPE);

       Our initial table attributes for products are productID, description and unit.
We issue this command to create our first table:

       CREATE TABLE products ( productID VARCHAR(5),
       description VARCHAR(50), unit VARCHAR(3));




Page 3 of 7                                 http://ThrivingAndLiving.blogspot.com
To check the structure of products table, we use DESCRIBE <tablename> to show
its composition. Figure 5 has the output:




                                Figure 5. Creating a Table

Alter Table and Set up Primary Key

All relational database tables should have a primary key/s that will identify uniqueness of
row/record. On our products table, we will set productID as the primary key. We issue
the following command:

       ALTER TABLE products
       ADD PRIMARY KEY (productID);

        What you have noticed here is the use of ADD PRIMARY KEY command in setting
up the productID as our primary key. As we again describe the structure of our table, Figure
6 shows the output:




                     Figure 6. Setting up of productID as primary key


Page 4 of 7                                 http://ThrivingAndLiving.blogspot.com
We may even add additional columns/attributes that will further describe data for
products. Let us add column date_created on our table.

       ALTER TABLE products
       ADD date_created DATE;

       Describing the table again after the ALTER command shows on Figure 7.




                           Figure 7. Adding date_created column

The INSERT Command
The INSERT INTO statement is used to insert new rows/records into a table. After the
VALUES keyword, a comma-separated list of column names follows:

       INSERT INTO <table_name> (<column1>, <column2>….)
       VALUES (<value1, value2…);

       Let us insert and execute the following statement:

              INSERT INTO products (productID, description, unit, date_created)
              VALUES (‘PC001’, ‘Compaq laptop computer’,’ea’, ‘2009-11-23’);

       Issue another insert:

              INSERT INTO products (productID, description, unit, date_created)
              VALUES (‘PC002’, ‘Dell Desktop computer’,’ea’, ‘2009-11-22’);

        To see if the following rows were successfully added, we will use SELECT statement
to display all rows. * represents all rows.


Page 5 of 7                                 http://ThrivingAndLiving.blogspot.com
SELECT * FROM products;

       Figure 8 shows the output of the two rows insertion upon displaying it with SELECT
statement:




                  Figure 8. Display of records after a SELECT statement



Using UPDATE statement

This command is used to modify the data in the table. It has the following syntax:

          UPDATE <table_name>
          SET <column_name> = new_value
          WHERE < where condition> ;

          If we want to correct PC002’s Description to a value ‘Dell laptop computer’, our
statement will be:

              UPDATE products
              SET description =’Dell laptop computer’
              WHERE productID = ‘PC002’;

       We have used WHERE clause in the statement to qualify what data is to be modified,
thereby limiting the scope of the update.

       Again, SELECT statement is used to display changes. See Figure 9.




Page 6 of 7                                 http://ThrivingAndLiving.blogspot.com
Figure 9. Using UPDATE statement

Deleting Records from Table
The DELETE statement is used to delete rows from table and returns the number of rows
deleted. Below is the syntax that uses also a WHERE clause to identify the criteria of what
data should be removed:

       DELETE FROM <table_name>
       WHERE < where condition>;

       Let us delete productID which has a value of ‘PC001’.

              DELETE FROM products
              WHERE productID = ‘PC001’;

       We issue again a SELECT statement to see the deletion was done. Figure 10 shows
it.




                        Figure 10. Issuing a DELETE statement.



Page 7 of 7                                http://ThrivingAndLiving.blogspot.com

More Related Content

What's hot

SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
Dan D'Urso
 
Sql presentation 1 by chandan
Sql presentation 1 by chandanSql presentation 1 by chandan
Sql presentation 1 by chandan
Linux international training Center
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commandsBelle Wx
 
Dbms practical list
Dbms practical listDbms practical list
Dbms practical list
RajSingh734307
 
Creating Views - oracle database
Creating Views - oracle databaseCreating Views - oracle database
Creating Views - oracle database
Salman Memon
 
Application development using Microsoft SQL Server 2000
Application development using Microsoft SQL Server 2000Application development using Microsoft SQL Server 2000
Application development using Microsoft SQL Server 2000webhostingguy
 
Subqueriesandjoins unit6
Subqueriesandjoins unit6Subqueriesandjoins unit6
Subqueriesandjoins unit6Jenip Shrestha
 
Sql views
Sql viewsSql views
Sql views
arshid045
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
DataminingTools Inc
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
1keydata
 
Getting Started with MySQL II
Getting Started with MySQL IIGetting Started with MySQL II
Getting Started with MySQL II
Sankhya_Analytics
 
Sql ch 13 - sql-views
Sql ch 13 - sql-viewsSql ch 13 - sql-views
Sql ch 13 - sql-views
Mukesh Tekwani
 
Step bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecordStep bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecordMilind Patil
 
Sq lite
Sq liteSq lite
Producing Readable Output with iSQL*Plus - Oracle Data Base
Producing Readable Output with iSQL*Plus - Oracle Data BaseProducing Readable Output with iSQL*Plus - Oracle Data Base
Producing Readable Output with iSQL*Plus - Oracle Data Base
Salman Memon
 
White paper a complete guide to oracle bi discoverer end user layer
White paper  a complete guide to oracle bi discoverer end user layerWhite paper  a complete guide to oracle bi discoverer end user layer
White paper a complete guide to oracle bi discoverer end user layerLatha Rajendran
 
Les08 (manipulating data)
Les08 (manipulating data)Les08 (manipulating data)
Les08 (manipulating data)
Achmad Solichin
 
Dbms lab Manual
Dbms lab ManualDbms lab Manual
Dbms lab Manual
Vivek Kumar Sinha
 

What's hot (20)

SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
 
Sql presentation 1 by chandan
Sql presentation 1 by chandanSql presentation 1 by chandan
Sql presentation 1 by chandan
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
Dbms practical list
Dbms practical listDbms practical list
Dbms practical list
 
Creating Views - oracle database
Creating Views - oracle databaseCreating Views - oracle database
Creating Views - oracle database
 
Application development using Microsoft SQL Server 2000
Application development using Microsoft SQL Server 2000Application development using Microsoft SQL Server 2000
Application development using Microsoft SQL Server 2000
 
Subqueriesandjoins unit6
Subqueriesandjoins unit6Subqueriesandjoins unit6
Subqueriesandjoins unit6
 
Sql views
Sql viewsSql views
Sql views
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
 
Mysql cheatsheet
Mysql cheatsheetMysql cheatsheet
Mysql cheatsheet
 
Sql basics
Sql  basicsSql  basics
Sql basics
 
Getting Started with MySQL II
Getting Started with MySQL IIGetting Started with MySQL II
Getting Started with MySQL II
 
Sql ch 13 - sql-views
Sql ch 13 - sql-viewsSql ch 13 - sql-views
Sql ch 13 - sql-views
 
Step bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecordStep bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecord
 
Sq lite
Sq liteSq lite
Sq lite
 
Producing Readable Output with iSQL*Plus - Oracle Data Base
Producing Readable Output with iSQL*Plus - Oracle Data BaseProducing Readable Output with iSQL*Plus - Oracle Data Base
Producing Readable Output with iSQL*Plus - Oracle Data Base
 
White paper a complete guide to oracle bi discoverer end user layer
White paper  a complete guide to oracle bi discoverer end user layerWhite paper  a complete guide to oracle bi discoverer end user layer
White paper a complete guide to oracle bi discoverer end user layer
 
Les08 (manipulating data)
Les08 (manipulating data)Les08 (manipulating data)
Les08 (manipulating data)
 
Dbms lab Manual
Dbms lab ManualDbms lab Manual
Dbms lab Manual
 

Viewers also liked

Mil senderos por recorrer
Mil senderos por recorrerMil senderos por recorrer
Mil senderos por recorrer
guadalinfolataha
 
Texas Star Chart Campus Results
Texas Star Chart Campus ResultsTexas Star Chart Campus Results
Texas Star Chart Campus Results
Jana Cash
 
งานนำเสนอ1
งานนำเสนอ1งานนำเสนอ1
งานนำเสนอ1
Tömáñg Käëwnöppärät
 
Button controls and using methods to make a simple web browser
Button controls and using methods to make a simple web browserButton controls and using methods to make a simple web browser
Button controls and using methods to make a simple web browserSecondary School
 
Introduction to computing
Introduction to computingIntroduction to computing
Introduction to computing
Secondary School
 
Proyecto mil senderos por recorrer
Proyecto mil senderos por recorrerProyecto mil senderos por recorrer
Proyecto mil senderos por recorrer
guadalinfolataha
 
Administrative assistant ri-z
Administrative assistant ri-zAdministrative assistant ri-z
Administrative assistant ri-zRosaiqbal
 
Microbial fuel cell
Microbial fuel cellMicrobial fuel cell
Microbial fuel cell
Natalia Sacco
 
Coco Sugar
Coco SugarCoco Sugar
Coco Sugar
Sowmya Reddy
 
Vigin Coconut Oil(VCO)
Vigin Coconut Oil(VCO)Vigin Coconut Oil(VCO)
Vigin Coconut Oil(VCO)
Sowmya Reddy
 
C.V. David Labbé, M.Sc., agr., chm.
C.V. David Labbé, M.Sc., agr., chm.C.V. David Labbé, M.Sc., agr., chm.
C.V. David Labbé, M.Sc., agr., chm.
davidlabbe
 
15.project attendence managemnt system
15.project attendence managemnt system15.project attendence managemnt system
15.project attendence managemnt systemHaseeb Nasir
 

Viewers also liked (15)

Mil senderos por recorrer
Mil senderos por recorrerMil senderos por recorrer
Mil senderos por recorrer
 
Texas Star Chart Campus Results
Texas Star Chart Campus ResultsTexas Star Chart Campus Results
Texas Star Chart Campus Results
 
งานนำเสนอ1
งานนำเสนอ1งานนำเสนอ1
งานนำเสนอ1
 
Button controls and using methods to make a simple web browser
Button controls and using methods to make a simple web browserButton controls and using methods to make a simple web browser
Button controls and using methods to make a simple web browser
 
Introduction to computing
Introduction to computingIntroduction to computing
Introduction to computing
 
Extending the web browser
Extending the web browserExtending the web browser
Extending the web browser
 
Dooms day
Dooms dayDooms day
Dooms day
 
Virtualidad
VirtualidadVirtualidad
Virtualidad
 
Proyecto mil senderos por recorrer
Proyecto mil senderos por recorrerProyecto mil senderos por recorrer
Proyecto mil senderos por recorrer
 
Administrative assistant ri-z
Administrative assistant ri-zAdministrative assistant ri-z
Administrative assistant ri-z
 
Microbial fuel cell
Microbial fuel cellMicrobial fuel cell
Microbial fuel cell
 
Coco Sugar
Coco SugarCoco Sugar
Coco Sugar
 
Vigin Coconut Oil(VCO)
Vigin Coconut Oil(VCO)Vigin Coconut Oil(VCO)
Vigin Coconut Oil(VCO)
 
C.V. David Labbé, M.Sc., agr., chm.
C.V. David Labbé, M.Sc., agr., chm.C.V. David Labbé, M.Sc., agr., chm.
C.V. David Labbé, M.Sc., agr., chm.
 
15.project attendence managemnt system
15.project attendence managemnt system15.project attendence managemnt system
15.project attendence managemnt system
 

Similar to mysql 1st. act.

chapter 8 SQL.ppt
chapter 8 SQL.pptchapter 8 SQL.ppt
chapter 8 SQL.ppt
YitbarekMurche
 
chap 7.ppt(sql).ppt
chap 7.ppt(sql).pptchap 7.ppt(sql).ppt
chap 7.ppt(sql).ppt
arjun431527
 
Using Mysql.pptx
Using Mysql.pptxUsing Mysql.pptx
Using Mysql.pptx
StephenEfange3
 
MySQL
MySQLMySQL
SQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxSQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptx
KashifManzoorMeo
 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL I
Sankhya_Analytics
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
Bwsrang Basumatary
 
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdfmysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
pradnyamulay
 
Les10
Les10Les10
Introduction to Oracle Database.pptx
Introduction to Oracle Database.pptxIntroduction to Oracle Database.pptx
Introduction to Oracle Database.pptx
SiddhantBhardwaj26
 
Oracle: Commands
Oracle: CommandsOracle: Commands
Oracle: Commands
oracle content
 
Oracle: DDL
Oracle: DDLOracle: DDL
Oracle: DDL
DataminingTools Inc
 
My sql with querys
My sql with querysMy sql with querys
My sql with querysNIRMAL FELIX
 
MySQL Presentation
MySQL PresentationMySQL Presentation
MySQL Presentation
Manish Bothra
 
Simple ado program by visual studio
Simple ado program by visual studioSimple ado program by visual studio
Simple ado program by visual studio
Aravindharamanan S
 
Simple ado program by visual studio
Simple ado program by visual studioSimple ado program by visual studio
Simple ado program by visual studio
Aravindharamanan S
 
DOODB_LAB.pptx
DOODB_LAB.pptxDOODB_LAB.pptx
DOODB_LAB.pptx
FilestreamFilestream
 

Similar to mysql 1st. act. (20)

chapter 8 SQL.ppt
chapter 8 SQL.pptchapter 8 SQL.ppt
chapter 8 SQL.ppt
 
Chap 7
Chap 7Chap 7
Chap 7
 
chap 7.ppt(sql).ppt
chap 7.ppt(sql).pptchap 7.ppt(sql).ppt
chap 7.ppt(sql).ppt
 
Using Mysql.pptx
Using Mysql.pptxUsing Mysql.pptx
Using Mysql.pptx
 
Mysql
MysqlMysql
Mysql
 
MySQL
MySQLMySQL
MySQL
 
SQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxSQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptx
 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL I
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
 
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdfmysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
 
Les10
Les10Les10
Les10
 
Introduction to Oracle Database.pptx
Introduction to Oracle Database.pptxIntroduction to Oracle Database.pptx
Introduction to Oracle Database.pptx
 
Oracle: Commands
Oracle: CommandsOracle: Commands
Oracle: Commands
 
Oracle: DDL
Oracle: DDLOracle: DDL
Oracle: DDL
 
My sql with querys
My sql with querysMy sql with querys
My sql with querys
 
MySQL Presentation
MySQL PresentationMySQL Presentation
MySQL Presentation
 
Ch 9 S Q L
Ch 9  S Q LCh 9  S Q L
Ch 9 S Q L
 
Simple ado program by visual studio
Simple ado program by visual studioSimple ado program by visual studio
Simple ado program by visual studio
 
Simple ado program by visual studio
Simple ado program by visual studioSimple ado program by visual studio
Simple ado program by visual studio
 
DOODB_LAB.pptx
DOODB_LAB.pptxDOODB_LAB.pptx
DOODB_LAB.pptx
 

Recently uploaded

Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 

Recently uploaded (20)

Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 

mysql 1st. act.

  • 1. Laboratory Activity 1 MySQL Basics Objectives At the end of the activity, student is expected to perform the following:  Run MySQL command line  Display available databases  Create database and tables  Alter table and set up primary key  Insert, update and delete tables Run MySQL Command Line Prompt We run MySQL prompt, click Start | Programs | MySQL | MySQL Server 5.1 | MySQL Command Line Client. See Figure 1. If you are prompted with a password, type the password that you have assigned during running of MySQL Server Instance Config Wizard or simply hit enter from keyboard. Figure 1. Launching of Command Prompt Window Page 1 of 7 http://ThrivingAndLiving.blogspot.com
  • 2. Figure 2 shows the mysql command prompt line . You are now on MySQL Server environment. Figure 2. MySQL command prompt Display Available Databases MySQL comes with default databases upon installation. These are information_schema, mysql and test. Mysql and information_schema databases are special databases where MySql server stores various access permissions. Test database is used for various testing features and sample databases. To display all the available databases on the server we type: SHOW DATABASES; Please take note that all commands should be terminated with semicolon to signal MySQL that a command is completed and ready for execution. Figure 3 should show the output of the command. Figure 3. Databases available currently at server Page 2 of 7 http://ThrivingAndLiving.blogspot.com
  • 3. Create Database We will now create our own (new) database. Let us say that the name of our database is my_store. Command syntax for creating database is CREATE DATABASE <database name>. Figure 4 displays the creation of my_store database after issuing the SHOW DATABASES command. Figure 4. my_store database is created Create Table within the Database Database consists of table/s where we store rows and columns. Creating a database does not mean you open it automatically. USE <database name> is the syntax in opening a database. In order to open my_store database we issue: USE my_store; We will create now a table products to hold all products data within the database. Our products table consists of attributes/fieldnames vital in identifying description about a product. Syntax in creating a table has this format: CREATE TABLE <table name> ( <fieldname1> DATA TYPE, <fieldname2> DATA TYPE… <fieldnameN> DATA TYPE); Our initial table attributes for products are productID, description and unit. We issue this command to create our first table: CREATE TABLE products ( productID VARCHAR(5), description VARCHAR(50), unit VARCHAR(3)); Page 3 of 7 http://ThrivingAndLiving.blogspot.com
  • 4. To check the structure of products table, we use DESCRIBE <tablename> to show its composition. Figure 5 has the output: Figure 5. Creating a Table Alter Table and Set up Primary Key All relational database tables should have a primary key/s that will identify uniqueness of row/record. On our products table, we will set productID as the primary key. We issue the following command: ALTER TABLE products ADD PRIMARY KEY (productID); What you have noticed here is the use of ADD PRIMARY KEY command in setting up the productID as our primary key. As we again describe the structure of our table, Figure 6 shows the output: Figure 6. Setting up of productID as primary key Page 4 of 7 http://ThrivingAndLiving.blogspot.com
  • 5. We may even add additional columns/attributes that will further describe data for products. Let us add column date_created on our table. ALTER TABLE products ADD date_created DATE; Describing the table again after the ALTER command shows on Figure 7. Figure 7. Adding date_created column The INSERT Command The INSERT INTO statement is used to insert new rows/records into a table. After the VALUES keyword, a comma-separated list of column names follows: INSERT INTO <table_name> (<column1>, <column2>….) VALUES (<value1, value2…); Let us insert and execute the following statement: INSERT INTO products (productID, description, unit, date_created) VALUES (‘PC001’, ‘Compaq laptop computer’,’ea’, ‘2009-11-23’); Issue another insert: INSERT INTO products (productID, description, unit, date_created) VALUES (‘PC002’, ‘Dell Desktop computer’,’ea’, ‘2009-11-22’); To see if the following rows were successfully added, we will use SELECT statement to display all rows. * represents all rows. Page 5 of 7 http://ThrivingAndLiving.blogspot.com
  • 6. SELECT * FROM products; Figure 8 shows the output of the two rows insertion upon displaying it with SELECT statement: Figure 8. Display of records after a SELECT statement Using UPDATE statement This command is used to modify the data in the table. It has the following syntax: UPDATE <table_name> SET <column_name> = new_value WHERE < where condition> ; If we want to correct PC002’s Description to a value ‘Dell laptop computer’, our statement will be: UPDATE products SET description =’Dell laptop computer’ WHERE productID = ‘PC002’; We have used WHERE clause in the statement to qualify what data is to be modified, thereby limiting the scope of the update. Again, SELECT statement is used to display changes. See Figure 9. Page 6 of 7 http://ThrivingAndLiving.blogspot.com
  • 7. Figure 9. Using UPDATE statement Deleting Records from Table The DELETE statement is used to delete rows from table and returns the number of rows deleted. Below is the syntax that uses also a WHERE clause to identify the criteria of what data should be removed: DELETE FROM <table_name> WHERE < where condition>; Let us delete productID which has a value of ‘PC001’. DELETE FROM products WHERE productID = ‘PC001’; We issue again a SELECT statement to see the deletion was done. Figure 10 shows it. Figure 10. Issuing a DELETE statement. Page 7 of 7 http://ThrivingAndLiving.blogspot.com