SlideShare a Scribd company logo
Dr. D. P.
Mishra
Digitally signed by Dr. D. P.
Mishra
DN: cn=Dr. D. P. Mishra,
o=durg, ou=BIT,
email=dpmishra@bitdurg.ac.
in, c=IN
Date: 2023.04.10 14:01:56
+05'30'
hour=$(date +%H)
if [ $hour -ge 5 -a $hour -lt 12 ];
then
echo "Good morning, $USER!"
elif [ $hour -ge 12 -a $hour -lt 18 ];
then
echo "Good afternoon, $USER!"
else
echo "Good evening, $USER!"
fi
```
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
10.1 Shell script to wish according to day
time.
clear
option=y
while [ $option = y ]
do
echo "1. Symbolic mode 2.
Absolute mode"
echo "enter your choice"
read ch
case $ch in
echo;;
2) clear
echo "changing the permission is
absolute mode"
echo `pwd` contents are
ls -l
echo "enter the filename"
read fname
echo "enter the permission"
read permission
chmod $permission $fname
echo "after changind the file
permission"
ls –l
echo;;
esac
echo "do you want to continue y/n "
read option
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
10.2 Shell script to assign a file permission to a given file using
a) symbolic mode b) absolute mode
1) clear
echo "changing the file permission in
symbolic mode"
echo `pwd` contents are
ls -l
echo "enter the file name"
read fname
echo "enter the file type u/g/o"
read type
echo "enter one of the permission
r/w/x"
read permission
#changing the mode with given input
chmod $type+$permission $fname
echo "after changing the permission"
ls -l
MYSQL
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Connecting to MySQL
MySQL provides an interactive shell fo creating tables,
inserting data, etc.
Mysql or
mysql -u user -p;
Note : $ sudo - i
Provide Password : BitDurg#123
# mysql
mysql>
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
To exit the MySQL Shell, just type QUIT or
EXIT:
mysql>
mysql> QUIT
mysql> exit
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Basic Queries
• Once logged in, you can try some simple queries.
• For example:
mysql> SELECT VERSION(), CURRENT_DATE;
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Basic Queries ..
•Keywords may be entered in any lettercase.
•The following queries are equivalent:
mysql> SELECT VERSION(), CURRENT_DATE;
mysql> select version(), current_date;
mysql> SeLeCt vErSiOn(), current_DATE;
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Basic Queries …
• Here's another query. It demonstrates that
• you can use mysql as a simple calculator:
mysql> SELECT SIN(PI()/4), (4+1)*5;
+-------------+---------+
| SIN(PI()/4) |(4+1)*5 |
+-------------+---------+
| 0.707107 | 25 |
+-------------+---------+
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Basic Queries ….
• You can also enter multiple statements on a single
• line. Just end each one with a semicolon:
mysql> SELECT VERSION(); SELECT NOW();
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Multi-Line Commands
• mysql determines where your statement ends by looking for the
terminating semicolon, not by looking for the end of the input line.
• Here's a simple multiple-line statement:
mysql> SELECT
-> USER()
-> ,
-> CURRENT_DATE;
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Command prompt
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Cancelling a Command
• If you decide you don't want to execute a command that you are in the
process of entering, cancel it by typing c
mysql> SELECT
-> USER()
-> c
mysql>
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Info about databases and tables
Listing the databases on the MySQL server host
mysql>show databases;
Access/change database
mysql>Use [database_name]
Showing the current selected database
mysql> select database();
Showing tables in the current database
mysql>show tables;
Showing the structure of a table
mysql> describe [table_name];
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Using Database
• To get started on your own database, first check which databases
currently exist.
• Use the SHOW statement to find out which databases currently exist
on the server
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Creating & Using Database
• To create a new database, issue the “create database” command:
mysql> create database webdb;
• Note: Database names are case sensitive
• To the select a database, issue the “use” command:
mysql> use webdb;
To see what database is selected
mysql> select database();
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Creating a Table
• Once you have selected a database, you can view all database tables:
mysql> show tables;
Empty set (0.02 sec)
• An empty set indicates that I have not created any tables yet.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
• Let’s create a table for storing pets.
• Table: pets
• name: VARCHAR(20)
• owner: VARCHAR(20)
• species: VARCHAR(20)
• sex: CHAR(1)
• birth: DATE
• date: DATE
• VARCHAR is usually used to store
string data.
mysql> CREATE TABLE pet (
-> name VARCHAR(20),
-> owner VARCHAR(20),
-> species VARCHAR(20),
-> sex CHAR(1),
-> birth DATE, death DATE);
Query OK, 0 rows affected (0.04
sec)
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Creating a Table..
Showing Tables
• To verify that the table has been created:
mysql> show tables;
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Describing table
• To view a table structure, use the DESCRIBE command:
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Deleting a Table
• To delete an entire table, use the DROP TABLE command:
mysql> drop table pet;
Query OK, 0 rows affected (0.02 sec)
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Inserting Data
•Use the INSERT statement to enter data into a table.
•For example:
INSERT INTO pet VALUES
('Puffball','Diane','hamster','f',
'1999-03-30',NULL);
•The next slide shows a full set of sample data.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
More Data
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Loading Sample Data
• You could create a text file `pet.txt‘ containing one record per line.
• Values must be separated by tabs, and given in the order in which the
columns were listed in the CREATE TABLE statement.
• Then load the data via the LOAD DATA Command.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Sample Data File
To Load pet.txt:
mysql> LOAD DATA LOCAL INFILE "pet.txt" INTO TABLE pet;
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Manipulating table instances
•Remove records of a table
– mysql> DELETE FROM tableName;
– [WHERE where_condition];
•Update records of a table
– UPDATE pet SET birth = '1989-
08-31' WHERE name ='Bowser';
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
SQL Select
• The SELECT statement is used to pull information from a table.
• The general format is:
SELECT what_to_select
FROM which_table
WHERE conditions_to_satisfy
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Selecting All Data
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Selecting Particular Rows
• You can select only particular rows from your table.
• For example, if you want to verify the change that you made to
Bowser's birth date, select Bowser's record like this:
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Selecting Particular Rows
• To find all animals born after 1998
SELECT * FROM pet WHERE birth >= "1998-1-1";
• To find all female dogs, use a logical AND
SELECT * FROM pet WHERE species = "dog" AND sex = "f";
• To find all snakes or birds, use a logical OR
SELECT * FROM pet WHERE species = "snake" OR species = "bird";
• AND has higher precedence than OR → Use parenthesis if necessary
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Selecting Particular Columns
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Sorting Data
• To sort data use order by clause , ex : to view animals birthdays, sorted
by birth
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Sorting in reverse order
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Selecting Particular Row
• Find out who owns pets
SELECT owner FROM pet;
• Find out who owns pets (without duplicate)
SELECT DISTINCT owner FROM pet;
• Get birth dates for male dogs and female cats
SELECT name, species, birth FROM pet WHERE (species = "dog"
AND sex=”m”) OR (species = "cat" AND sex=”f”);
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Pattern Matching Examples
• To find names beginning with ‘b’:
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Pattern matching ..
• Finding the names ending with ‘fy’
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Pattern Matching ..
• Finding name containing ‘w’
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Counting Rows
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Counting Rows Example ..
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Selecting Particular Rows
• Find out number of animals per species
SELECT species, count(*) FROM pet GROUP BY species;
• Find out number of animals per sex
SELECT sex, count(*) FROM pet GROUP BY sex;
• Find out number of animals per combination of species and sex
SELECT species, sex, count(*) FROM pet GROUP BY species, sex;
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
MySQL

More Related Content

Similar to MySQL

Postgres the best tool you're already using
Postgres the best tool you're already usingPostgres the best tool you're already using
Postgres the best tool you're already using
LiquidPlanner
 
Well Grounded Python Coding - Revision 1 (Day 1 Slides)
Well Grounded Python Coding - Revision 1 (Day 1 Slides)Well Grounded Python Coding - Revision 1 (Day 1 Slides)
Well Grounded Python Coding - Revision 1 (Day 1 Slides)
Worajedt Sitthidumrong
 
Well Grounded Python Coding - Revision 1 (Day 1 Handouts)
Well Grounded Python Coding - Revision 1 (Day 1 Handouts)Well Grounded Python Coding - Revision 1 (Day 1 Handouts)
Well Grounded Python Coding - Revision 1 (Day 1 Handouts)
Worajedt Sitthidumrong
 
File and directories in python
File and directories in pythonFile and directories in python
File and directories in python
Lifna C.S
 
Unix lab
Unix labUnix lab
Python fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuanPython fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuan
Wei-Yuan Chang
 
Lecture3 mysql gui by okello erick
Lecture3 mysql gui by okello erickLecture3 mysql gui by okello erick
Lecture3 mysql gui by okello erick
okelloerick
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
Pongsakorn U-chupala
 
Postgresql Database Administration Basic - Day2
Postgresql  Database Administration Basic  - Day2Postgresql  Database Administration Basic  - Day2
Postgresql Database Administration Basic - Day2
PoguttuezhiniVP
 
Oracle Tracing
Oracle TracingOracle Tracing
Oracle Tracing
Merin Mathew
 
PostgreSQL 9.6 새 기능 소개
PostgreSQL 9.6 새 기능 소개PostgreSQL 9.6 새 기능 소개
PostgreSQL 9.6 새 기능 소개
PgDay.Seoul
 
mysql-Tutorial with Query presentation.ppt
mysql-Tutorial with Query presentation.pptmysql-Tutorial with Query presentation.ppt
mysql-Tutorial with Query presentation.ppt
aptechaligarh
 
Bioinformatics p5-bioperl v2013-wim_vancriekinge
Bioinformatics p5-bioperl v2013-wim_vancriekingeBioinformatics p5-bioperl v2013-wim_vancriekinge
Bioinformatics p5-bioperl v2013-wim_vancriekinge
Prof. Wim Van Criekinge
 
Beating the Blockchain by Mapping Out Decentralized Namecoin and Emercoin Inf...
Beating the Blockchain by Mapping Out Decentralized Namecoin and Emercoin Inf...Beating the Blockchain by Mapping Out Decentralized Namecoin and Emercoin Inf...
Beating the Blockchain by Mapping Out Decentralized Namecoin and Emercoin Inf...
Priyanka Aash
 
MySQL for beginners
MySQL for beginnersMySQL for beginners
MySQL for beginners
Saeid Zebardast
 
Perl Programming - 04 Programming Database
Perl Programming - 04 Programming DatabasePerl Programming - 04 Programming Database
Perl Programming - 04 Programming Database
Danairat Thanabodithammachari
 

Similar to MySQL (20)

Postgres the best tool you're already using
Postgres the best tool you're already usingPostgres the best tool you're already using
Postgres the best tool you're already using
 
Well Grounded Python Coding - Revision 1 (Day 1 Slides)
Well Grounded Python Coding - Revision 1 (Day 1 Slides)Well Grounded Python Coding - Revision 1 (Day 1 Slides)
Well Grounded Python Coding - Revision 1 (Day 1 Slides)
 
Well Grounded Python Coding - Revision 1 (Day 1 Handouts)
Well Grounded Python Coding - Revision 1 (Day 1 Handouts)Well Grounded Python Coding - Revision 1 (Day 1 Handouts)
Well Grounded Python Coding - Revision 1 (Day 1 Handouts)
 
File and directories in python
File and directories in pythonFile and directories in python
File and directories in python
 
Unix lab
Unix labUnix lab
Unix lab
 
Python fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuanPython fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuan
 
Lecture3 mysql gui by okello erick
Lecture3 mysql gui by okello erickLecture3 mysql gui by okello erick
Lecture3 mysql gui by okello erick
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 
Intro to my sql
Intro to my sqlIntro to my sql
Intro to my sql
 
Intro to my sql
Intro to my sqlIntro to my sql
Intro to my sql
 
Postgresql Database Administration Basic - Day2
Postgresql  Database Administration Basic  - Day2Postgresql  Database Administration Basic  - Day2
Postgresql Database Administration Basic - Day2
 
Solr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene EuroconSolr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene Eurocon
 
Oracle Tracing
Oracle TracingOracle Tracing
Oracle Tracing
 
PostgreSQL 9.6 새 기능 소개
PostgreSQL 9.6 새 기능 소개PostgreSQL 9.6 새 기능 소개
PostgreSQL 9.6 새 기능 소개
 
mysql-Tutorial with Query presentation.ppt
mysql-Tutorial with Query presentation.pptmysql-Tutorial with Query presentation.ppt
mysql-Tutorial with Query presentation.ppt
 
Bioinformatics p5-bioperl v2013-wim_vancriekinge
Bioinformatics p5-bioperl v2013-wim_vancriekingeBioinformatics p5-bioperl v2013-wim_vancriekinge
Bioinformatics p5-bioperl v2013-wim_vancriekinge
 
Beating the Blockchain by Mapping Out Decentralized Namecoin and Emercoin Inf...
Beating the Blockchain by Mapping Out Decentralized Namecoin and Emercoin Inf...Beating the Blockchain by Mapping Out Decentralized Namecoin and Emercoin Inf...
Beating the Blockchain by Mapping Out Decentralized Namecoin and Emercoin Inf...
 
MySQL for beginners
MySQL for beginnersMySQL for beginners
MySQL for beginners
 
Perl Programming - 04 Programming Database
Perl Programming - 04 Programming DatabasePerl Programming - 04 Programming Database
Perl Programming - 04 Programming Database
 
NOTES ON "FOXPRO"
NOTES ON "FOXPRO" NOTES ON "FOXPRO"
NOTES ON "FOXPRO"
 

More from BIT DURG

HTML_DOM
HTML_DOMHTML_DOM
HTML_DOM
BIT DURG
 
JavaScript
JavaScriptJavaScript
JavaScript
BIT DURG
 
Understanding WWW
Understanding WWWUnderstanding WWW
Understanding WWW
BIT DURG
 
Computer Networks
Computer NetworksComputer Networks
Computer Networks
BIT DURG
 
Computer Basics
Computer Basics Computer Basics
Computer Basics
BIT DURG
 
ISDN & ATM
ISDN & ATMISDN & ATM
ISDN & ATM
BIT DURG
 
Transport Control Protocol
Transport Control ProtocolTransport Control Protocol
Transport Control Protocol
BIT DURG
 
Routing Protocols
Routing ProtocolsRouting Protocols
Routing Protocols
BIT DURG
 
Internet Protocol.pdf
Internet Protocol.pdfInternet Protocol.pdf
Internet Protocol.pdf
BIT DURG
 
Intternetworking With TCP/IP
Intternetworking With TCP/IPIntternetworking With TCP/IP
Intternetworking With TCP/IP
BIT DURG
 
Computer Network Basics
Computer Network BasicsComputer Network Basics
Computer Network Basics
BIT DURG
 
Types of Linux Shells
Types of Linux Shells Types of Linux Shells
Types of Linux Shells
BIT DURG
 
File Access Permission
File Access PermissionFile Access Permission
File Access Permission
BIT DURG
 
Basic Shell Programs
Basic Shell ProgramsBasic Shell Programs
Basic Shell Programs
BIT DURG
 
Linux Installation
Linux InstallationLinux Installation
Linux Installation
BIT DURG
 
Basics of GNU & Linux
Basics of GNU & LinuxBasics of GNU & Linux
Basics of GNU & Linux
BIT DURG
 
National youth day
National youth dayNational youth day
National youth day
BIT DURG
 
Visual Basic Tutorials
Visual Basic TutorialsVisual Basic Tutorials
Visual Basic Tutorials
BIT DURG
 
Oss the freedom dpm 2018
Oss the freedom dpm 2018Oss the freedom dpm 2018
Oss the freedom dpm 2018
BIT DURG
 

More from BIT DURG (19)

HTML_DOM
HTML_DOMHTML_DOM
HTML_DOM
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Understanding WWW
Understanding WWWUnderstanding WWW
Understanding WWW
 
Computer Networks
Computer NetworksComputer Networks
Computer Networks
 
Computer Basics
Computer Basics Computer Basics
Computer Basics
 
ISDN & ATM
ISDN & ATMISDN & ATM
ISDN & ATM
 
Transport Control Protocol
Transport Control ProtocolTransport Control Protocol
Transport Control Protocol
 
Routing Protocols
Routing ProtocolsRouting Protocols
Routing Protocols
 
Internet Protocol.pdf
Internet Protocol.pdfInternet Protocol.pdf
Internet Protocol.pdf
 
Intternetworking With TCP/IP
Intternetworking With TCP/IPIntternetworking With TCP/IP
Intternetworking With TCP/IP
 
Computer Network Basics
Computer Network BasicsComputer Network Basics
Computer Network Basics
 
Types of Linux Shells
Types of Linux Shells Types of Linux Shells
Types of Linux Shells
 
File Access Permission
File Access PermissionFile Access Permission
File Access Permission
 
Basic Shell Programs
Basic Shell ProgramsBasic Shell Programs
Basic Shell Programs
 
Linux Installation
Linux InstallationLinux Installation
Linux Installation
 
Basics of GNU & Linux
Basics of GNU & LinuxBasics of GNU & Linux
Basics of GNU & Linux
 
National youth day
National youth dayNational youth day
National youth day
 
Visual Basic Tutorials
Visual Basic TutorialsVisual Basic Tutorials
Visual Basic Tutorials
 
Oss the freedom dpm 2018
Oss the freedom dpm 2018Oss the freedom dpm 2018
Oss the freedom dpm 2018
 

Recently uploaded

14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
top1002
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 

Recently uploaded (20)

14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 

MySQL

  • 1. Dr. D. P. Mishra Digitally signed by Dr. D. P. Mishra DN: cn=Dr. D. P. Mishra, o=durg, ou=BIT, email=dpmishra@bitdurg.ac. in, c=IN Date: 2023.04.10 14:01:56 +05'30'
  • 2. hour=$(date +%H) if [ $hour -ge 5 -a $hour -lt 12 ]; then echo "Good morning, $USER!" elif [ $hour -ge 12 -a $hour -lt 18 ]; then echo "Good afternoon, $USER!" else echo "Good evening, $USER!" fi ``` Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg 10.1 Shell script to wish according to day time.
  • 3. clear option=y while [ $option = y ] do echo "1. Symbolic mode 2. Absolute mode" echo "enter your choice" read ch case $ch in echo;; 2) clear echo "changing the permission is absolute mode" echo `pwd` contents are ls -l echo "enter the filename" read fname echo "enter the permission" read permission chmod $permission $fname echo "after changind the file permission" ls –l echo;; esac echo "do you want to continue y/n " read option Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg 10.2 Shell script to assign a file permission to a given file using a) symbolic mode b) absolute mode 1) clear echo "changing the file permission in symbolic mode" echo `pwd` contents are ls -l echo "enter the file name" read fname echo "enter the file type u/g/o" read type echo "enter one of the permission r/w/x" read permission #changing the mode with given input chmod $type+$permission $fname echo "after changing the permission" ls -l
  • 5. Connecting to MySQL MySQL provides an interactive shell fo creating tables, inserting data, etc. Mysql or mysql -u user -p; Note : $ sudo - i Provide Password : BitDurg#123 # mysql mysql> Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 6. To exit the MySQL Shell, just type QUIT or EXIT: mysql> mysql> QUIT mysql> exit Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 7. Basic Queries • Once logged in, you can try some simple queries. • For example: mysql> SELECT VERSION(), CURRENT_DATE; Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 8. Basic Queries .. •Keywords may be entered in any lettercase. •The following queries are equivalent: mysql> SELECT VERSION(), CURRENT_DATE; mysql> select version(), current_date; mysql> SeLeCt vErSiOn(), current_DATE; Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 9. Basic Queries … • Here's another query. It demonstrates that • you can use mysql as a simple calculator: mysql> SELECT SIN(PI()/4), (4+1)*5; +-------------+---------+ | SIN(PI()/4) |(4+1)*5 | +-------------+---------+ | 0.707107 | 25 | +-------------+---------+ Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 10. Basic Queries …. • You can also enter multiple statements on a single • line. Just end each one with a semicolon: mysql> SELECT VERSION(); SELECT NOW(); Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 11. Multi-Line Commands • mysql determines where your statement ends by looking for the terminating semicolon, not by looking for the end of the input line. • Here's a simple multiple-line statement: mysql> SELECT -> USER() -> , -> CURRENT_DATE; Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 13. Cancelling a Command • If you decide you don't want to execute a command that you are in the process of entering, cancel it by typing c mysql> SELECT -> USER() -> c mysql> Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 14. Info about databases and tables Listing the databases on the MySQL server host mysql>show databases; Access/change database mysql>Use [database_name] Showing the current selected database mysql> select database(); Showing tables in the current database mysql>show tables; Showing the structure of a table mysql> describe [table_name]; Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 15. Using Database • To get started on your own database, first check which databases currently exist. • Use the SHOW statement to find out which databases currently exist on the server Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 16. Creating & Using Database • To create a new database, issue the “create database” command: mysql> create database webdb; • Note: Database names are case sensitive • To the select a database, issue the “use” command: mysql> use webdb; To see what database is selected mysql> select database(); Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 17. Creating a Table • Once you have selected a database, you can view all database tables: mysql> show tables; Empty set (0.02 sec) • An empty set indicates that I have not created any tables yet. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 18. • Let’s create a table for storing pets. • Table: pets • name: VARCHAR(20) • owner: VARCHAR(20) • species: VARCHAR(20) • sex: CHAR(1) • birth: DATE • date: DATE • VARCHAR is usually used to store string data. mysql> CREATE TABLE pet ( -> name VARCHAR(20), -> owner VARCHAR(20), -> species VARCHAR(20), -> sex CHAR(1), -> birth DATE, death DATE); Query OK, 0 rows affected (0.04 sec) Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg Creating a Table..
  • 19. Showing Tables • To verify that the table has been created: mysql> show tables; Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 20. Describing table • To view a table structure, use the DESCRIBE command: Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 21. Deleting a Table • To delete an entire table, use the DROP TABLE command: mysql> drop table pet; Query OK, 0 rows affected (0.02 sec) Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 22. Inserting Data •Use the INSERT statement to enter data into a table. •For example: INSERT INTO pet VALUES ('Puffball','Diane','hamster','f', '1999-03-30',NULL); •The next slide shows a full set of sample data. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 24. Loading Sample Data • You could create a text file `pet.txt‘ containing one record per line. • Values must be separated by tabs, and given in the order in which the columns were listed in the CREATE TABLE statement. • Then load the data via the LOAD DATA Command. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 25. Sample Data File To Load pet.txt: mysql> LOAD DATA LOCAL INFILE "pet.txt" INTO TABLE pet; Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 26. Manipulating table instances •Remove records of a table – mysql> DELETE FROM tableName; – [WHERE where_condition]; •Update records of a table – UPDATE pet SET birth = '1989- 08-31' WHERE name ='Bowser'; Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 27. SQL Select • The SELECT statement is used to pull information from a table. • The general format is: SELECT what_to_select FROM which_table WHERE conditions_to_satisfy Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 29. Selecting Particular Rows • You can select only particular rows from your table. • For example, if you want to verify the change that you made to Bowser's birth date, select Bowser's record like this: Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 30. Selecting Particular Rows • To find all animals born after 1998 SELECT * FROM pet WHERE birth >= "1998-1-1"; • To find all female dogs, use a logical AND SELECT * FROM pet WHERE species = "dog" AND sex = "f"; • To find all snakes or birds, use a logical OR SELECT * FROM pet WHERE species = "snake" OR species = "bird"; • AND has higher precedence than OR → Use parenthesis if necessary Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 32. Sorting Data • To sort data use order by clause , ex : to view animals birthdays, sorted by birth Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 33. Sorting in reverse order Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 34. Selecting Particular Row • Find out who owns pets SELECT owner FROM pet; • Find out who owns pets (without duplicate) SELECT DISTINCT owner FROM pet; • Get birth dates for male dogs and female cats SELECT name, species, birth FROM pet WHERE (species = "dog" AND sex=”m”) OR (species = "cat" AND sex=”f”); Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 35. Pattern Matching Examples • To find names beginning with ‘b’: Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 36. Pattern matching .. • Finding the names ending with ‘fy’ Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 37. Pattern Matching .. • Finding name containing ‘w’ Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 39. Counting Rows Example .. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 40. Selecting Particular Rows • Find out number of animals per species SELECT species, count(*) FROM pet GROUP BY species; • Find out number of animals per sex SELECT sex, count(*) FROM pet GROUP BY sex; • Find out number of animals per combination of species and sex SELECT species, sex, count(*) FROM pet GROUP BY species, sex; Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg