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

SQL Notes

The document provides an introduction to SQL and relational databases. It discusses that DBMS are used to manage databases and connect to query or modify data. It also covers that there are two main types of DBMS - relational and non-relational. Relational databases store data in tables that can be linked together, with SQL used to query and modify the data. Popular RDBMS are mentioned. The document then discusses how to create databases and schemas to organize data. It provides details on using SQL statements like SELECT, FROM, WHERE to retrieve data from single tables, specifying columns and filters.

Uploaded by

Asad Riaz
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL Notes

The document provides an introduction to SQL and relational databases. It discusses that DBMS are used to manage databases and connect to query or modify data. It also covers that there are two main types of DBMS - relational and non-relational. Relational databases store data in tables that can be linked together, with SQL used to query and modify the data. Popular RDBMS are mentioned. The document then discusses how to create databases and schemas to organize data. It provides details on using SQL statements like SELECT, FROM, WHERE to retrieve data from single tables, specifying columns and filters.

Uploaded by

Asad Riaz
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

SQL NOTES

Introduction:
 In order to manage our databases, we use a software application called DBMS.
 We connect with DBMS for querying or modifying data
 DBMS will execute our instructions and sends data back

 There are two types of DBMS

 In RELATIONAL Database we store data in tables linked to each other using relationship.

 Each table stores data about a specific object like Customers tables contains customers data,
Products table contains products data and Order table contains orders data.
 SQL (Structured Query Language) is a database which works with the Relational DBMS
 We use SQL to query or modify our data

 There are many RDBMS (Relational Database Management System) out there:

-------------------------------------------------------------------------------------------------------------------------------------

HOW TO CREATE A DATABASE


 Administrative: We use it do administrative tasks such as starting or
stopping our server, importing and exporting data and so on.
 Schemas: It shows that how much databases we have in our current
database server
--------------------------------------------------------------------------------------------------------

RETRIEVING DATA FROM A SINGLE TABLE


The SELECT Statement
 In our navigator panel if no database is bold, it means that no database is
selected for querying.
 First to get the data from the database, select the database.
 SQL is not a case sensitive language but it is a best practice to CAPITALIZE
the built-in clauses like USE, SELECT, UPDATE and so on and use
LOWERCASE for anything else.
 For selecting a Database, we use “USE” statement.
 We use SELECT Clause to Retrieve or Extract data
 We use FROM Clause to know that from which table we want data to be
extracted.
 WHERE clause  To filter
 ORDER BY clause  for sorting
 We use the “ORDER BY” Clause, here we specify the column that we want
to sort the result on.

Note: The order of the clauses must always be:


SELECT  FROM  WHERE  ORDER BY

SELECT CLAUSE:
The “AS” known as Alias is used to name a new column which we have added
using any expression like arithmetic expression:
 If we want space in discount_factor then we use “ or ‘ like ‘discount factor’
 Use “DISTINCT” Keyword to remove duplication

 Before using DISTINCT KEYWORD 


 After using DISTINCT KEYWORD:

The “WHERE” Clause


 There “WHERE” Clause is used to filter data
 For example we need the customers with the points greater than 3000
Use sql_store;
Select * SQL Code
From customers
Where points > 3000

 ! = and <> are the called not equal


 The format in SQL is ‘Year-Month-Day’
 Date is not a string but we enclosed it with single notation

The order precedence of logical operators are AND  OR

You might also like