SQL STATEMENTS - Notes Lyst1769
SQL STATEMENTS - Notes Lyst1769
SQL - Day 5
Agenda
Case Study
What is Query?
A query is a question, often expressed in a formal way. A database query can be
either a select query or an action query. A select query is a data retrieval query,
while an action query asks for additional operations on the data, such as insertion,
updating or deletion.
OUTPUT:
NOTE: Query which we have written had fetched all the student details whose
grade is greater than 70% from STUDENT table and given a separate table as
shown (output) above.
Unlike SELECT command there are many different types of command available in
SQL.
SQL
Commands
Note: SQL statements are categorised into different languages and all the sql
commands are categorised into these different languages as shown below.
DDL commands:
CREATE – is used to create the database or its objects (like table, index,
function, views, store procedure and triggers).
TRUNCATE–is used to remove all records from a table, including all spaces
allocated for the records are removed.
DQL statements are used for performing queries on the data within database
table
DQL Commands:
DML (Data Manipulation Language): The SQL commands that deals with the
manipulation of data present in the database belong to DML or Data
Manipulation Language and this includes most of the SQL statements.
DML Commands:
DCL (Data Control Language): DCL includes commands such as GRANT and
REVOKE which mainly deal with the rights, permissions and other controls of
the database system.
DCL commands:
TCL (transaction Control Language): TCL commands deal with the transaction
within the database.
TCL commands:
How to establish a
Connection with MYSQL
server.
Before establishing the connection first install the MYSQL in your system.
MySQL command:
Invokes the MYSQL
sever
Note: Using the above SQL query we can fetch all the data present inside the
database.
Syntax:
CREATE database_name
SHOW TABLES
command is used to find
the data present inside
current database.
Note: We have created university database but no data has been added to it,
so it is displaying as EMPTY SET. Whenever data is not added into the
database then it displays EMPTY SET.
Syntax:
Drop DATABASE database_name
Note: Once the database is deleted/dropped from the server, then it cannot be
used. If we try to use the database which is not present inside the database
server then it will generate Error message.
To be continued…