0% found this document useful (0 votes)
18 views10 pages

MYSQL

Uploaded by

samidoks4jesus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views10 pages

MYSQL

Uploaded by

samidoks4jesus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

MYS

QL
CMP 313
MYSQL

SQL is the standard language for dealing with Relational Databases.

SQL is used to insert,search,update, and delete database records

● MySQL is an open-source relational database management system (RDBMS).


● Developed by Oracle Corporation.
● Widely used for web applications and other data-driven projects.

● SQL keywords are NOT case sensitive: select is the same as SELECT
MYSQL - Commands
● SELECT - extracts or gets data from a database
● UPDATE - updates or modify data in a database
● DELETE - deletes/removes data from a database
● INSERT INTO - inserts new data into a database
● CREATE DATABASE - creates a new database
● ALTER DATABASE - modifies a database
● CREATE TABLE - creates a new table
● ALTER TABLE - modifies a table
● DROP TABLE - deletes a table
● CREATE INDEX - creates an index (search key)
● DROP INDEX - deletes/removes an index
MYSQL - Commands
MySQL CREATE DATABASE Statement

The CREATE DATABASE statement is used to create a new SQL database.

Syntax:

CREATE DATABASE databasename;

MySQL DROP DATABASE Statement

The DROP DATABASE statement is used to drop an existing SQL database.

Syntax:

DROP DATABASE databasename;


MYSQL - Commands
The MySQL SELECT Statement

The SELECT statement is used to select data from a database.

Syntax:
SELECT column1, column2, ...

FROM table_name;

OR

SELECT * FROM table_name;


MYSQL - Commands
The MySQL WHERE Clause

The WHERE clause is used to filter records.


It is used to extract only those records that fulfill a specified condition.
Syntax:
SELECT column1, column2, ...
FROM table_name
WHERE condition;

Note: The WHERE clause is not only used in SELECT statements, it is also used in UPDATE, DELETE, etc.!

The MySQL UPDATE Statement


The UPDATE statement is used to modify the existing records in a table.

Note: Be careful when updating records in a table! Notice the WHERE clause in the UPDATE statement. The WHERE
clause specifies which record(s) that should be updated. If you omit the WHERE clause, all records in the table will be
updated!
Syntax:
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
MYSQL - Commands
MySQL DELETE Statement

The DELETE statement is used to delete existing records in a table.

Syntax:

DELETE FROM table_name WHERE condition;

EXAMPLE:
DELETE FROM Customers WHERE CustomerName='Alfreds Futterkiste';
MYSQL - Commands
MySQL AND, OR and NOT Operators

The WHERE clause can be combined with AND, OR, and NOT operators.
The AND and OR operators are used to filter records based on more than one condition:

● The AND operator displays a record if all the conditions separated by AND are TRUE.
● The OR operator displays a record if any of the conditions separated by OR is TRUE.

The NOT operator displays a record if the condition(s) is NOT TRUE.

Syntax
SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND/OR/NOT condition2 AND/OR/NOT condition3 ...;
MYSQL - Commands
MySQL INSERT INTO Statement

The INSERT INTO statement is used to insert new records in a table.

Syntax:
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);

MySQL ALTER TABLE Statement

The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.
The ALTER TABLE statement is also used to add and drop various constraints on an existing table.

Syntax:
ALTER TABLE table_name
ADD column_name datatype;
MYSQL - Commands
MySQL INSERT INTO Statement

The INSERT INTO statement is used to insert new records in a table.

Syntax:
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);

MySQL ALTER TABLE Statement

The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.
The ALTER TABLE statement is also used to add and drop various constraints on an existing table.

Syntax:
ALTER TABLE table_name
ADD column_name datatype;

You might also like