0% found this document useful (0 votes)
55 views22 pages

Introduction To Structured Query Language (SQL) : Ms. Kielly Chrizza Mae T. Lara

This document provides an introduction to Structured Query Language (SQL). It defines SQL, its purpose for database management, and discusses the different categories of SQL functions including data definition language (DDL) and data manipulation language (DML). Key SQL concepts covered include database structure, table creation, primary and foreign keys, indexes, and common data manipulation commands like SELECT, INSERT, UPDATE, and DELETE. The document aims to familiarize readers with basic SQL syntax and tasks.

Uploaded by

Albert Rama
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)
55 views22 pages

Introduction To Structured Query Language (SQL) : Ms. Kielly Chrizza Mae T. Lara

This document provides an introduction to Structured Query Language (SQL). It defines SQL, its purpose for database management, and discusses the different categories of SQL functions including data definition language (DDL) and data manipulation language (DML). Key SQL concepts covered include database structure, table creation, primary and foreign keys, indexes, and common data manipulation commands like SELECT, INSERT, UPDATE, and DELETE. The document aims to familiarize readers with basic SQL syntax and tasks.

Uploaded by

Albert Rama
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/ 22

Introduction to

Structured Query
Language (SQL)

Ms. KIELLY CHRIZZA MAE T. LARA


INSTRUCTOR
COLLEGE OF INFORMATION TECHNOLOGY, ENTERTAINMENT
AND COMMUNICATION, UBLC
Learning Objectives

• In this chapter, you will learn:


– Define SQL, its purpose and importance in database
management
– Familiarize the SQL syntax
– Enumerate and discuss the different DML and DDL
SQL languages
What is SQL?
What is SQL?

• SQL stands for Structured Query


language, pronounced as "S-Q-L" or sometimes as
"See-Quel".
• SQL is the standard language for dealing with
Relational Databases.
• SQL can be used to insert, search, update and delete
database records.
• SQL can do lots of other operations including
optimizing and maintenance of databases.
• Relational databases like MySQL Database, Oracle,
Ms SQL server, Sybase, etc uses SQL.
How to use sql syntaxes?

• SQL Example

SQL keyword Table Name Condition


Structured Query
Language (SQL)

• Categories of SQL function


– Data definition language (DDL)
– Data manipulation language (DML)
• Nonprocedural language with basic
command vocabulary set of less than 100
words
• Differences in SQL dialects are minor
Table 2.1 - SQL Data
Definition Command
Table 2.2 - SQL Data
Manipulation Commands
Figure 2.1 - The Database
Model
Tasks to be Completed
Before Using a New RDBMS

• Create database structure


– RDBMS creates physical files that will hold
database
– Differs from one RDBMS to another
• Authentication: Process DBMS uses to verify
that only registered users access the data
– Required for the creation tables
– User should log on to RDBMS using user ID
and password created by database
administrator
The Database Schema

• Logical group of database objects related


to each other
• Command
– CREATE SCHEMA AUTHORIZATION
{creator};
• Seldom used directly
Common SQL Data Types

Numeric

• NUMBER(L,D) or NUMERIC(L,D)

Character

• CHAR(L)
• VARCHAR(L) or VARCHAR2(L)

Date

• DATE
Creating Table Structures

• Use one line per column (attribute) definition


• Use spaces to line up attribute characteristics
and constraints
• Table and attribute names are capitalized
• Features of table creating command sequence
– NOT NULL specification
– UNIQUE specification
• Syntax to create table
– CREATE TABLE tablename();
Primary Key and Foreign
Key

• Primary key attributes contain both a NOT NULL


and a UNIQUE specification
• RDBMS will automatically enforce referential
integrity for foreign keys
• Command sequence ends with semicolon
• ANSI SQL allows use of following clauses to
cover CASCADE, SET NULL, or SET DEFAULT
– ON DELETE and ON UPDATE
SQL Constraints

NOT NULL
• Ensures that column does not accept nulls

UNIQUE
• Ensures that all values in column are unique

DEFAULT
• Assigns value to attribute when a new row is added to table

CHECK
• Validates data when attribute value is entered
SQL Indexes

• When primary key is declared, DBMS


automatically creates unique index
• Composite index:
– Is based on two or more attributes
– Prevents data duplication
• Syntax to create SQL indexes
– CREATE INDEX indexname ON tablename();
• Syntax to delete an index
– DROP INDEX indexname;
Data Manipulation Commands

INSERT: Command to insert data into table


• Syntax - INSERT INTO tablename VALUES();
• Used to add table rows with NULL and NOT NULL
attributes

COMMIT: Command to save changes

• Syntax - COMMIT [WORK];


• Ensures database update integrity
Data Manipulation Commands

SELECT: Command to list the contents


• Syntax - SELECT columnlist FROM tablename;
• Wildcard character(*): Substitute for other
characters/command

UPDATE: Command to modify data


• Syntax - UPDATE tablename SET columnname =
expression [, columnname = expression] [WHERE
conditionlist];
Data Manipulation Commands

WHERE condition
• Specifies the rows to be selected
ROLLBACK: Command to restore the database
• Syntax - ROLLBACK;
• Undoes the changes since last COMMIT
command
DELETE: Command to delete
• Syntax - DELETE FROM tablename
• [WHERE conditionlist];
Review Questions

1. Explain the concept and function of SQL


as a language used in database
management system.

2. Give at least three (3) DDL and DML.


Laboratory Task
REFERENCE:

• https://www.guru99.com/introduction-to-
mysql-workbench.html

You might also like