0% found this document useful (0 votes)
6 views19 pages

SQL - Introduction To SQL - L1

Uploaded by

mustaa9363
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
0% found this document useful (0 votes)
6 views19 pages

SQL - Introduction To SQL - L1

Uploaded by

mustaa9363
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 19

SQL [L1]

Introduction to SQL
By: Wahib Ladham
YEU@2024
Contents of this Lecture
Here’s what you’ll find in this Lecture:

1. Introduction to Structured Query Language.


2. Installing Oracle and setting up the environment.
3. Basic Syntax.
Introduction
to SQL
About SQL
SQL stands for Structured Query Language which is a computer language for storing,
manipulating and retrieving data stored in a relational database. SQL was developed in
the 1970s by IBM Computer Scientists and became a standard of the American National
Standards Institute (ANSI) in 1986, and the International Organization for Standardization
(ISO) in 1987.

SQL is the standard language to communicate with Relational Database Systems. All the
Relational Database Management Systems (RDMS) like MySQL, MS Access, Oracle, Sybase,
Informix, Postgres and SQL Server use SQL as their Standard Database Language.

SQL (Structured Query Language) is a language to operate databases; it includes Database


Creation, Database Deletion, Fetching Data Rows, Modifying & Deleting Data rows, etc.
Why Learn SQL?
SQL is essential for managing and handling data in various applications, from small-scale
programs to large enterprise systems.

SQL is widely popular because it offers the following advantages −


• Allows users to access data in the relational database management systems.
• Allows users to describe the data.
• Allows users to define the data in a database and manipulate that data.
• Allows to embed within other languages using SQL modules, libraries & pre-compilers.
• Allows users to create and drop databases and tables.
• Allows users to create view, stored procedure, functions in a database.
• Allows users to set permissions on tables, procedures and views.
Key Concepts in SQL
Database
• Databases: Explain what a database
is – a structured collection of data
stored and accessed electronically.

• Tables: Define tables as the primary


structure in a database that holds
data in rows and columns.

• Schemas: Describe schemas as a


logical structure that represents the
organization of data within a
database, including tables, views,
and relationships.
How SQL Works?
When you are executing an SQL command
for any RDBMS, the system determines the
best way to carry out your request and
SQL engine figures out how to interpret
the task.

There are various components included in


this process. These components are −
• Query Dispatcher
• Optimization Engines
• Classic Query Engine
• SQL Query Engine, etc.
SQL Databases
SQL or Relational databases are used
to store and manage the data objects
that are related to one another, i.e.
the process of handling data in a
relational database is done based on
a relational model.

This relational model is an approach


to manage data in a structured way
(using tables). A system used to
manage these relational databases is
known as Relational Database
Management System (RDBMS).
SQL Database Table Structure
SQL database server stores data in table form. Tables are database objects used to collect data in
Row and Column format. Rows represent the entities whereas columns define the attributes of
each entity in a table.
Columns: Columns are vertical elements in a table. Each column in a table holds specific attribute
information, and column properties such as column name and data types (Integer, Char, String,
etc).
Rows: Rows are horizontal elements in a table and users can add data or retrieve by executing SQL
queries.
Data Transformation
Level 01 - Raw Data (Text Files):
• Plain text format (e.g., .txt, .csv).
• No specific structure other than delimiter-based (e.g., commas, tabs).
Level 02 - Spreadsheet Files (Excel)
• Structured format with rows and columns (e.g., .xls, .xlsx).
• Supports formulas, charts, and pivot tables.
Level 03 - JSON and XML Files:
• Hierarchical data formats (JSON: JavaScript Object Notation, XML: eXtensible Markup
Language).
• Suitable for semi-structured data.
Level 04 - Relational Databases (RDBMS)
• Data stored in tables with rows and columns.
• Supports SQL for querying and managing data.
Getting Started
with SQL
Database Objects
Associated with each database user is a schema. A schema is a collection of schema objects.
Examples of schema objects include tables, views, sequences, synonyms, indexes etc. Schema
objects are logical data storage structures. Schema objects do not have a one-to-one
correspondence to physical files on disk that store their information. However, Oracle stores a
schema object logically within a tablespace of the database. The data of each object is
physically contained in one or more of the tablespace's datafiles. For some objects such as
tables, indexes, and clusters, you can specify how much disk space Oracle allocates for the
object within the tablespace's datafiles.

Table Stores data

View Subset of data from one or more tables

Sequence Generates numeric values

Index Improves the performance of some queries

Synonym Gives alternative names to objects


SQL - Syntax
What is SQL Syntax?
SQL syntax:
is a unique set of rules and guidelines to be followed while writing SQL statements. This tutorial
gives you a quick start with SQL by listing all the basic SQL Syntax.
All the SQL statements start with any of the keywords like SELECT, INSERT, UPDATE, DELETE,
ALTER, DROP, CREATE, USE, SHOW and all the statements end with a semicolon (;).

Case Sensitivity:
The most important point to be noted here is that SQL is case insensitive, which means SELECT
and Select have same meaning in SQL statements. Whereas, MySQL makes difference in table
names. So, if you are working with MySQL, then you need to give table names as they exist in
the database.
SQL Statements (commands)
Naming Rules
• Table names and column names must begin with a letter and be 1–30 characters long.
• Names must contain only the characters A–Z, a–z, 0–9, _ (underscore), $,
and # (legal characters, but their use is discouraged).

• Names must not duplicate the name of another object owned by the same Oracle server user.
• Names must not be an Oracle server reserved word.
• Use descriptive names for tables and other database objects.
• Note: Names are case-insensitive. For example, EMPLOYEES is treated as the same name as
eMPloyees or eMpLOYEES.
Data Types
An SQL data type refers to the type
of data which can be stored in a
column of a database table. In a
column, the user can store numeric,
string, binary, etc by defining data
types.
For example integer data, character
data, monetary data, date and time
data, binary strings, and so on.
While creating a database table in a
database, we need to specify
following two attributes to define a
table column –
• Name of the column
• Data type of the column
Table Example
Resources
SQL at:
WEBSITE: docs.oracle.com
WEBSITE: www.tutorialspoint.com/
WEBSITE: geeksforgeeks.org

You might also like