0% found this document useful (0 votes)
1 views

C-MYSQL

MySQL is a relational database management system that provides multi-user access to databases and is widely used in web applications. SQL, or Structured Query Language, is the standard language for accessing and manipulating databases, allowing users to perform various operations such as querying, inserting, updating, and deleting records. The document outlines the basic commands and functionalities of MySQL, including data definition, manipulation, and control languages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

C-MYSQL

MySQL is a relational database management system that provides multi-user access to databases and is widely used in web applications. SQL, or Structured Query Language, is the standard language for accessing and manipulating databases, allowing users to perform various operations such as querying, inserting, updating, and deleting records. The document outlines the basic commands and functionalities of MySQL, including data definition, manipulation, and control languages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

MYSQL

Prepared by:
Rochelle B. Cadayong
MYSQL
• is a relational database management system
(RDBMS)that runs as a server providing multi-user
access to a number of databases.
• It is named after developer Michael Widenius '
daughter, My
• The SQL phrase stands for Structured Query
Language.
• It is free: open source software
USES OF MYSQL
• MySQL is a popular choice of database for use in
web applications, and is a central component of the
widely-used LAMP,WAMP,XAMMP web application
software stack.
WHAT IS SQL?
• Pronounced “S-Q-L” by some and “sequel” by others.
• SQL stands for Structured Query Language.
• SQL is a standard language for accessing and
manipulating databases.
• SQL is an ANSI (American National Standards
Institute) standard
WHAT SQL CAN DO?
• SQL can execute queries against a database
• SQL can retrieve data from a database
• SQL can insert records in a database
• SQL can update records in a database
• SQL can delete records from a database
• SQL can create new databases
• SQL can create new tables in a database
• SQL can create stored procedures in a database
• SQL can create views in a database
• SQL can set permissions on tables, procedures, and views
SQL IS A STANDARD – BUT...
• Although SQL is an ANSI (American National
Standards Institute) standard, there are different
versions of the SQL language.
• However, to be compliant with the ANSI standard,
they all support at least the major commands (such
as SELECT, UPDATE, DELETE, INSERT, WHERE) in a
similar manner.
THE SQL ENVIRONMENT
1. CATALOG
2. SCHEMA
3. DATA DEFINITION LANGUAGE(DDL)
4. DATA MANIPULATION LANGUAGE(DML)
5. DATA CONTROL LANGUAGE(DCL)
CATALOG
• Consists of a set of tables and views which describe
tables, views, indexes, packages, procedures,
functions, files, sequences, triggers, and constraints.
• A catalog is automatically created when you create a
schema. You cannot drop or explicitly change the
catalog.
SCHEMA
• Consists of a library, a journal, a journal receiver, an
SQL catalog, and optionally a data dictionary. A
schema groups related objects and allows you to find
the objects by name.
DATA DEFINITION LANGUAGE
• Statements are used to define the database
structure or schema. Some examples:
▫ CREATE - to create objects in the database
▫ ALTER - alters the structure of the database
▫ DROP - delete objects from the database
DATA MANIPULATION LANGUAGE
• Statements are used for managing data within
schema objects. Some examples:
▫ SELECT - retrieve data from the a database
▫ INSERT - insert data into a table
▫ UPDATE - updates existing data within a table
▫ DELETE - deletes all records from a table, the space
for the records remain.
DATA CONTROL LANGUAGE
• Statements are used for giving a user access
privileges. Some examples:
▫ GRANT - gives user's access privileges to database
▫ REVOKE - withdraw access privileges given with
the GRANT command
SQL DATA TYPES
MYSQL BASIC COMMANDS - DDL

• CREATE
▫ How to create a database
● CREATE database database_name;
● Create database sample_db;
▫ How to create a table
● CREATE table table_name(fieldname1
datatype(size),fieldname2 datatype(size));

● Create table stud_info(ln varchar(255),fn


varchar(255),grade int);
MYSQL BASIC COMMANDS - DDL

• ALTER
▫ How to change a column/field name
● ALTER table table_name change old_fieldname
new_fieldname datatype(size);
Example:
ALTER table stud_info change ln lastname varchar(255);
▫ How to add column/field
ALTER table table_name add fieldname datatype(size);
Example:
Alter table stud_info add age int;
▫ How to drop a column/field
ALTER table table_name drop fieldname;
Alter table stud_info drop age;
MYSQL BASIC COMMANDS - DDL

• DROP
▫ How to drop a table
● DROP table table_name;
● Drop table stud_info;
▫ How to drop a database
● DROP database database_name;
● Drop database sample_db;
MYSQL BASIC COMMANDS - DML

• INSERT
▫ How to add records
● INSERT into table_name(fieldname1,fieldname2)
values(‘value1’,’value2’);
● Insert into stud_info(ln,fn,age)
values(‘Cadayong’,’Rochelle’,12);
● Insert into stud_info values(‘Cadayong’,’Rochelle’,12);
• SELECT
▫ How to query records
● SELECT * from table_name; (All fields)
● Select * from stud_info;
● SELECT fieldname from table_name; (Specific field)
● Select ln,fn from stud_info;
MYSQL BASIC COMMANDS - DML

• UPDATE
▫ How to update records
● UPDATE table_name set fieldname=‘new value’
where condition;
● Update stud_info set ln=‘Alicante’ where fn=‘Rochelle’;

• DELETE
▫ How to delete records
● DELETE from table_name where condition;
● Delete from stud_info where ln=‘Alicante’;
MYSQL BASIC COMMANDS - DML

• UPDATE
▫ How to update records
● UPDATE table_name set fieldname=‘new value’
where condition;
● Update stud_info set ln=‘Alicante’ where fn=‘Rochelle’;

• DELETE
▫ How to delete records
● DELETE from table_name where condition;
● Delete from stud_info where ln=‘Alicante’;
THE END...
Thank you for listening...

You might also like