SlideShare a Scribd company logo
MySQL Database Overview MySQL Database Overview Instructor: Rick Palmer, SCWCD [email_address]
Topics Covered Database Concepts Standard CRUD Operations using MySQL
Database Concepts Refresher Entity: an object, concept, or event. Field (column): describes a single characteristic of an entity. Record (row): collection of fields (characteristics) describing each entity. Table: collection of records for a specific entity. Database: collection of tables.
MySQL Open Source relational database management system:  www.mysql.com   Supports Structured Query Language (SQL) – a standardized way to communicate with databases. Very popular (NASA, Yahoo, Powell's Books, Novell, U.S. Census Bureau, etc)
Navigating in MySQL Get a list of existing databases: mysql> show databases; Specify the database to use: mysql> use mysql; Get a list of tables in the database: mysql> show tables; Describe a table: mysql> describe user;
MySQL  C RUD Operations Create a new database: mysql> CREATE DATABASE cis; Create a new table: mysql> use cis; -> CREATE TABLE vehicles  -> (VIN varchar(17), Year int(4), Make varchar(20), ->  Model varchar(20), Mileage int(10)); Insert data into the table:   mysql> INSERT INTO vehicles (VIN, Year, Make, Model, Mileage)  -> VALUES ('8YTR754', 2002, 'Ford', 'Mustang', 21000); Create a SQL script describing the database :   C:\mysql\bin >   mysqldump –u root –p cis > cis.sql Create a database and data using a SQL script:   mysql> source C:\mysql\ bin\cis.sql  (NOTE: no semi-colon)
MySQL C R UD Operations Retrieving all data from a table: mysql> SELECT * FROM vehicles; +----------+-------+-----------+----------+----------+ | VIN  | Year  | Make  | Model  | Mileage  | +----------+-------+-----------+----------+----------+ | 8YTR754  | 2002  | Ford  | Mustang  | 21000  | | 4GKU390  | 2001  | Chevrolet | Corvette | 35000  | | 92A84UJ  | 1998  | Dodge  | Viper  | 89256  | +----------+-------+-----------+----------+----------+ Selecting a specific row of data: mysql> SELECT * FROM vehicles WHERE VIN = '8YTR754'; +----------+-------+-----------+----------+----------+ | VIN  | Year  | Make  | Model  | Mileage  | +----------+-------+-----------+----------+----------+ | 8YTR754  | 2002  | Ford  | Mustang  | 21000  | +----------+-------+-----------+----------+----------+
MySQL CR U D Operations Update all records in a table   mysql> UPDATE vehicles SET Mileage = 25000; Update specific records   mysql> UPDATE vehicles SET Mileage = 25000   -> WHERE  VIN = '8YTR754'; Update multiple columns of a specific record   mysql> UPDATE vehicles  -> SET Mileage = 25000, LastServiceDate = '08/30/2003' -> WHERE  VIN = '8YTR754';
MySQL CRU D  Operations Delete all rows in a table (does not delete table)   mysql> DELETE FROM vehicles; Delete specific rows in a table   mysql> DELETE FROM vehicles   -> WHERE  VIN = '8YTR754'; Delete the entire table (remove from database)   mysql> DROP TABLE vehicles;
Ad

More Related Content

What's hot (20)

Percona Live 2012PPT: introduction-to-mysql-replication
Percona Live 2012PPT: introduction-to-mysql-replicationPercona Live 2012PPT: introduction-to-mysql-replication
Percona Live 2012PPT: introduction-to-mysql-replication
mysqlops
 
Let's make a contract: the art of designing a Java API
Let's make a contract: the art of designing a Java APILet's make a contract: the art of designing a Java API
Let's make a contract: the art of designing a Java API
Mario Fusco
 
MySQL
MySQLMySQL
MySQL
Gouthaman V
 
Sql commands
Sql commandsSql commands
Sql commands
Pooja Dixit
 
HTML5 Tutorial
HTML5 TutorialHTML5 Tutorial
HTML5 Tutorial
Avinash Malhotra
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
Evolution Network
 
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
Edureka!
 
Introduction to CSS Grid Layout
Introduction to CSS Grid LayoutIntroduction to CSS Grid Layout
Introduction to CSS Grid Layout
Rachel Andrew
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
Mohd Tousif
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Jussi Pohjolainen
 
Introduction to Bootstrap
Introduction to BootstrapIntroduction to Bootstrap
Introduction to Bootstrap
Ron Reiter
 
SQL Server Stored procedures
SQL Server Stored proceduresSQL Server Stored procedures
SQL Server Stored procedures
Randy Riness @ South Puget Sound Community College
 
CSS Dasar #1 : Intro
CSS Dasar #1 : IntroCSS Dasar #1 : Intro
CSS Dasar #1 : Intro
Sandhika Galih
 
Interface result set
Interface result setInterface result set
Interface result set
myrajendra
 
Html Frames
Html FramesHtml Frames
Html Frames
Xainab Ishfaq
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
Bui Kiet
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
WebStackAcademy
 
Integrity constraints in dbms
Integrity constraints in dbmsIntegrity constraints in dbms
Integrity constraints in dbms
Vignesh Saravanan
 
Javascript
JavascriptJavascript
Javascript
mussawir20
 
Bootstrap
BootstrapBootstrap
Bootstrap
AvinashChunduri2
 
Percona Live 2012PPT: introduction-to-mysql-replication
Percona Live 2012PPT: introduction-to-mysql-replicationPercona Live 2012PPT: introduction-to-mysql-replication
Percona Live 2012PPT: introduction-to-mysql-replication
mysqlops
 
Let's make a contract: the art of designing a Java API
Let's make a contract: the art of designing a Java APILet's make a contract: the art of designing a Java API
Let's make a contract: the art of designing a Java API
Mario Fusco
 
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
Edureka!
 
Introduction to CSS Grid Layout
Introduction to CSS Grid LayoutIntroduction to CSS Grid Layout
Introduction to CSS Grid Layout
Rachel Andrew
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
Mohd Tousif
 
Introduction to Bootstrap
Introduction to BootstrapIntroduction to Bootstrap
Introduction to Bootstrap
Ron Reiter
 
Interface result set
Interface result setInterface result set
Interface result set
myrajendra
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
Bui Kiet
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
WebStackAcademy
 
Integrity constraints in dbms
Integrity constraints in dbmsIntegrity constraints in dbms
Integrity constraints in dbms
Vignesh Saravanan
 

Viewers also liked (20)

Introduction to MySQL
Introduction to MySQLIntroduction to MySQL
Introduction to MySQL
Giuseppe Maxia
 
The MySQL Server ecosystem in 2016
The MySQL Server ecosystem in 2016The MySQL Server ecosystem in 2016
The MySQL Server ecosystem in 2016
Colin Charles
 
Plsql
PlsqlPlsql
Plsql
NV Chandra Sekhar Nittala
 
PPT
PPTPPT
PPT
webhostingguy
 
Mysql
MysqlMysql
Mysql
Yuvaraja Rajenderan
 
Mysql1
Mysql1Mysql1
Mysql1
rajikaa
 
Download It
Download ItDownload It
Download It
webhostingguy
 
Mysql Introduction
Mysql IntroductionMysql Introduction
Mysql Introduction
hemant meena
 
Introduction to MySQL
Introduction to MySQLIntroduction to MySQL
Introduction to MySQL
Ted Wennmark
 
MySQL clients
MySQL clientsMySQL clients
MySQL clients
yoku0825
 
Mysql database
Mysql databaseMysql database
Mysql database
mayank78634
 
MySQL Sandbox 3
MySQL Sandbox 3MySQL Sandbox 3
MySQL Sandbox 3
Giuseppe Maxia
 
An introduction to MySQL
An introduction to MySQLAn introduction to MySQL
An introduction to MySQL
Creditas
 
BITS: Introduction to relational databases and MySQL - SQL
BITS: Introduction to relational databases and MySQL - SQLBITS: Introduction to relational databases and MySQL - SQL
BITS: Introduction to relational databases and MySQL - SQL
BITS
 
Mysql an introduction
Mysql an introductionMysql an introduction
Mysql an introduction
Mohd yasin Karim
 
MySQL Introduction
MySQL IntroductionMySQL Introduction
MySQL Introduction
mysql content
 
Introduction to Mysql
Introduction to MysqlIntroduction to Mysql
Introduction to Mysql
Tushar Chauhan
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
1keydata
 
CBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL PresentationCBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL Presentation
Guru Ji
 
Mysql introduction
Mysql introduction Mysql introduction
Mysql introduction
Prof. Wim Van Criekinge
 
The MySQL Server ecosystem in 2016
The MySQL Server ecosystem in 2016The MySQL Server ecosystem in 2016
The MySQL Server ecosystem in 2016
Colin Charles
 
Mysql Introduction
Mysql IntroductionMysql Introduction
Mysql Introduction
hemant meena
 
Introduction to MySQL
Introduction to MySQLIntroduction to MySQL
Introduction to MySQL
Ted Wennmark
 
MySQL clients
MySQL clientsMySQL clients
MySQL clients
yoku0825
 
An introduction to MySQL
An introduction to MySQLAn introduction to MySQL
An introduction to MySQL
Creditas
 
BITS: Introduction to relational databases and MySQL - SQL
BITS: Introduction to relational databases and MySQL - SQLBITS: Introduction to relational databases and MySQL - SQL
BITS: Introduction to relational databases and MySQL - SQL
BITS
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
1keydata
 
CBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL PresentationCBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL Presentation
Guru Ji
 
Ad

Similar to MySQL lecture (20)

Hands-On with U-SQL and Azure Data Lake Analytics (ADLA)
Hands-On with U-SQL and Azure Data Lake Analytics (ADLA)Hands-On with U-SQL and Azure Data Lake Analytics (ADLA)
Hands-On with U-SQL and Azure Data Lake Analytics (ADLA)
Jason L Brugger
 
Big Data Analytics with MariaDB ColumnStore
Big Data Analytics with MariaDB ColumnStoreBig Data Analytics with MariaDB ColumnStore
Big Data Analytics with MariaDB ColumnStore
MariaDB plc
 
ClickHouse Introduction by Alexander Zaitsev, Altinity CTO
ClickHouse Introduction by Alexander Zaitsev, Altinity CTOClickHouse Introduction by Alexander Zaitsev, Altinity CTO
ClickHouse Introduction by Alexander Zaitsev, Altinity CTO
Altinity Ltd
 
Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.
Mydbops
 
Cassandra, web scale no sql data platform
Cassandra, web scale no sql data platformCassandra, web scale no sql data platform
Cassandra, web scale no sql data platform
Marko Švaljek
 
Presentation
PresentationPresentation
Presentation
Dimitris Stripelis
 
MySQL SQL Tutorial
MySQL SQL TutorialMySQL SQL Tutorial
MySQL SQL Tutorial
Chien Chung Shen
 
5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...
5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...
5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...
Kangaroot
 
Cassandra Summit 2015: Intro to DSE Search
Cassandra Summit 2015: Intro to DSE SearchCassandra Summit 2015: Intro to DSE Search
Cassandra Summit 2015: Intro to DSE Search
Caleb Rackliffe
 
DataStax: An Introduction to DataStax Enterprise Search
DataStax: An Introduction to DataStax Enterprise SearchDataStax: An Introduction to DataStax Enterprise Search
DataStax: An Introduction to DataStax Enterprise Search
DataStax Academy
 
Non-Relational Postgres
Non-Relational PostgresNon-Relational Postgres
Non-Relational Postgres
EDB
 
MySQL as a Document Store
MySQL as a Document StoreMySQL as a Document Store
MySQL as a Document Store
Dave Stokes
 
Adding Complex Data to Spark Stack by Tug Grall
Adding Complex Data to Spark Stack by Tug GrallAdding Complex Data to Spark Stack by Tug Grall
Adding Complex Data to Spark Stack by Tug Grall
Spark Summit
 
MySQLinsanity
MySQLinsanityMySQLinsanity
MySQLinsanity
Stanley Huang
 
My SYSAUX tablespace is full - please help
My SYSAUX tablespace is full - please helpMy SYSAUX tablespace is full - please help
My SYSAUX tablespace is full - please help
Markus Flechtner
 
Big Data LDN 2017: Big Data Analytics with MariaDB ColumnStore
Big Data LDN 2017: Big Data Analytics with MariaDB ColumnStoreBig Data LDN 2017: Big Data Analytics with MariaDB ColumnStore
Big Data LDN 2017: Big Data Analytics with MariaDB ColumnStore
Matt Stubbs
 
MySQL 开发
MySQL 开发MySQL 开发
MySQL 开发
YUCHENG HU
 
NoSQL and MySQL: News about JSON
NoSQL and MySQL: News about JSONNoSQL and MySQL: News about JSON
NoSQL and MySQL: News about JSON
Mario Beck
 
Storing time series data with Apache Cassandra
Storing time series data with Apache CassandraStoring time series data with Apache Cassandra
Storing time series data with Apache Cassandra
Patrick McFadin
 
Big Data processing with Spark, Scala or Java?
Big Data processing with Spark, Scala or Java?Big Data processing with Spark, Scala or Java?
Big Data processing with Spark, Scala or Java?
Erik-Berndt Scheper
 
Hands-On with U-SQL and Azure Data Lake Analytics (ADLA)
Hands-On with U-SQL and Azure Data Lake Analytics (ADLA)Hands-On with U-SQL and Azure Data Lake Analytics (ADLA)
Hands-On with U-SQL and Azure Data Lake Analytics (ADLA)
Jason L Brugger
 
Big Data Analytics with MariaDB ColumnStore
Big Data Analytics with MariaDB ColumnStoreBig Data Analytics with MariaDB ColumnStore
Big Data Analytics with MariaDB ColumnStore
MariaDB plc
 
ClickHouse Introduction by Alexander Zaitsev, Altinity CTO
ClickHouse Introduction by Alexander Zaitsev, Altinity CTOClickHouse Introduction by Alexander Zaitsev, Altinity CTO
ClickHouse Introduction by Alexander Zaitsev, Altinity CTO
Altinity Ltd
 
Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.
Mydbops
 
Cassandra, web scale no sql data platform
Cassandra, web scale no sql data platformCassandra, web scale no sql data platform
Cassandra, web scale no sql data platform
Marko Švaljek
 
5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...
5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...
5_MariaDB_What's New in MariaDB Server 10.2 and Big Data Analytics with Maria...
Kangaroot
 
Cassandra Summit 2015: Intro to DSE Search
Cassandra Summit 2015: Intro to DSE SearchCassandra Summit 2015: Intro to DSE Search
Cassandra Summit 2015: Intro to DSE Search
Caleb Rackliffe
 
DataStax: An Introduction to DataStax Enterprise Search
DataStax: An Introduction to DataStax Enterprise SearchDataStax: An Introduction to DataStax Enterprise Search
DataStax: An Introduction to DataStax Enterprise Search
DataStax Academy
 
Non-Relational Postgres
Non-Relational PostgresNon-Relational Postgres
Non-Relational Postgres
EDB
 
MySQL as a Document Store
MySQL as a Document StoreMySQL as a Document Store
MySQL as a Document Store
Dave Stokes
 
Adding Complex Data to Spark Stack by Tug Grall
Adding Complex Data to Spark Stack by Tug GrallAdding Complex Data to Spark Stack by Tug Grall
Adding Complex Data to Spark Stack by Tug Grall
Spark Summit
 
My SYSAUX tablespace is full - please help
My SYSAUX tablespace is full - please helpMy SYSAUX tablespace is full - please help
My SYSAUX tablespace is full - please help
Markus Flechtner
 
Big Data LDN 2017: Big Data Analytics with MariaDB ColumnStore
Big Data LDN 2017: Big Data Analytics with MariaDB ColumnStoreBig Data LDN 2017: Big Data Analytics with MariaDB ColumnStore
Big Data LDN 2017: Big Data Analytics with MariaDB ColumnStore
Matt Stubbs
 
NoSQL and MySQL: News about JSON
NoSQL and MySQL: News about JSONNoSQL and MySQL: News about JSON
NoSQL and MySQL: News about JSON
Mario Beck
 
Storing time series data with Apache Cassandra
Storing time series data with Apache CassandraStoring time series data with Apache Cassandra
Storing time series data with Apache Cassandra
Patrick McFadin
 
Big Data processing with Spark, Scala or Java?
Big Data processing with Spark, Scala or Java?Big Data processing with Spark, Scala or Java?
Big Data processing with Spark, Scala or Java?
Erik-Berndt Scheper
 
Ad

More from webhostingguy (20)

File Upload
File UploadFile Upload
File Upload
webhostingguy
 
Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Framework
webhostingguy
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guide
webhostingguy
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3
webhostingguy
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web servers
webhostingguy
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidation
webhostingguy
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
webhostingguy
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
webhostingguy
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreement
webhostingguy
 
Notes8
Notes8Notes8
Notes8
webhostingguy
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
webhostingguy
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
webhostingguy
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructure
webhostingguy
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.ppt
webhostingguy
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy
webhostingguy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
webhostingguy
 
OLUG_xen.ppt
OLUG_xen.pptOLUG_xen.ppt
OLUG_xen.ppt
webhostingguy
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Products
webhostingguy
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mb
webhostingguy
 
Reseller's Guide
Reseller's GuideReseller's Guide
Reseller's Guide
webhostingguy
 
Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Framework
webhostingguy
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guide
webhostingguy
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3
webhostingguy
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web servers
webhostingguy
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidation
webhostingguy
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreement
webhostingguy
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
webhostingguy
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
webhostingguy
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructure
webhostingguy
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.ppt
webhostingguy
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy
webhostingguy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
webhostingguy
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Products
webhostingguy
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mb
webhostingguy
 

MySQL lecture

  • 1. MySQL Database Overview MySQL Database Overview Instructor: Rick Palmer, SCWCD [email_address]
  • 2. Topics Covered Database Concepts Standard CRUD Operations using MySQL
  • 3. Database Concepts Refresher Entity: an object, concept, or event. Field (column): describes a single characteristic of an entity. Record (row): collection of fields (characteristics) describing each entity. Table: collection of records for a specific entity. Database: collection of tables.
  • 4. MySQL Open Source relational database management system: www.mysql.com Supports Structured Query Language (SQL) – a standardized way to communicate with databases. Very popular (NASA, Yahoo, Powell's Books, Novell, U.S. Census Bureau, etc)
  • 5. Navigating in MySQL Get a list of existing databases: mysql> show databases; Specify the database to use: mysql> use mysql; Get a list of tables in the database: mysql> show tables; Describe a table: mysql> describe user;
  • 6. MySQL C RUD Operations Create a new database: mysql> CREATE DATABASE cis; Create a new table: mysql> use cis; -> CREATE TABLE vehicles -> (VIN varchar(17), Year int(4), Make varchar(20), -> Model varchar(20), Mileage int(10)); Insert data into the table: mysql> INSERT INTO vehicles (VIN, Year, Make, Model, Mileage) -> VALUES ('8YTR754', 2002, 'Ford', 'Mustang', 21000); Create a SQL script describing the database : C:\mysql\bin > mysqldump –u root –p cis > cis.sql Create a database and data using a SQL script: mysql> source C:\mysql\ bin\cis.sql (NOTE: no semi-colon)
  • 7. MySQL C R UD Operations Retrieving all data from a table: mysql> SELECT * FROM vehicles; +----------+-------+-----------+----------+----------+ | VIN | Year | Make | Model | Mileage | +----------+-------+-----------+----------+----------+ | 8YTR754 | 2002 | Ford | Mustang | 21000 | | 4GKU390 | 2001 | Chevrolet | Corvette | 35000 | | 92A84UJ | 1998 | Dodge | Viper | 89256 | +----------+-------+-----------+----------+----------+ Selecting a specific row of data: mysql> SELECT * FROM vehicles WHERE VIN = '8YTR754'; +----------+-------+-----------+----------+----------+ | VIN | Year | Make | Model | Mileage | +----------+-------+-----------+----------+----------+ | 8YTR754 | 2002 | Ford | Mustang | 21000 | +----------+-------+-----------+----------+----------+
  • 8. MySQL CR U D Operations Update all records in a table mysql> UPDATE vehicles SET Mileage = 25000; Update specific records mysql> UPDATE vehicles SET Mileage = 25000 -> WHERE VIN = '8YTR754'; Update multiple columns of a specific record mysql> UPDATE vehicles -> SET Mileage = 25000, LastServiceDate = '08/30/2003' -> WHERE VIN = '8YTR754';
  • 9. MySQL CRU D Operations Delete all rows in a table (does not delete table) mysql> DELETE FROM vehicles; Delete specific rows in a table mysql> DELETE FROM vehicles -> WHERE VIN = '8YTR754'; Delete the entire table (remove from database) mysql> DROP TABLE vehicles;

Editor's Notes

  • #3: CRUD stands for Create, Read (Select), Update, and Delete. These are the four main operations performed against a database. SQL (Structured Query Language) is a standard dialect for communicating with a database using terms like “INSERT” for creating data, “SELECT” for querying data, “UPDATE” for updating data, and “DELETE” for deleting data.
  • #4: Examples of an entity include real world object like a Vehicle, Employee, Order, or events like a Service Outage or a System Error. It’s the “thing” or set of things that a database represents, and the real-world objects around which businesses are based. Examples of Vehicle fields include properties of the Vehicle entity, such as the Vehicle year, make, model, and mileage. A record represents all the fields that describe the entity. If our database contains 3000 Vehicles, then it will have 300 rows of vehicles, each with their own distinct values in each field. A table is used to keep records for one entity separate from other entities, so that Vehicle records are stored separately from Employee records. In some ways, you can think of a table as a spreadsheet containing multiple rows and columns all related to the same entity. MySQL server contains multiple databases, which is common for database servers. Each database usually contains tables that are specific to an application or business group.
  • #6: Once you have installed MySQL and have started the command line client using the instructions provided in the Lesson 6 instructions, you will see a mysql> prompt. Enter the above commands at the prompt and begin to explore the databases that come installed with MySQL.
  翻译: