Introduction to SQL
• SQL (Structured Query Language) is a standard
language used to work with relational
databases.
• • Used to create, read, update, and delete
data
• • Works with MySQL, Oracle, SQL Server,
PostgreSQL
• • Declarative language
• • Standardized by ANSI and ISO
Objectives of SQL
• • Data Definition (CREATE, ALTER, DROP)
• • Data Manipulation (INSERT, UPDATE,
DELETE, SELECT)
• • Data Control (GRANT, REVOKE)
• • Data Integrity
• • Transaction Control
History of SQL
• • 1970: Relational Model by E.F. Codd
• • 1974: SEQUEL developed by IBM
• • 1979: Oracle released SQL-based DBMS
• • 1986: ANSI standard
• • 1987: ISO standard
Importance of SQL
• • Easy to learn
• • Handles large data
• • Supported by all major DBMS
• • Used in web and enterprise systems
• • Important skill for IT professionals
SQL Terminology
• • Database: Collection of data
• • Table: Rows and columns
• • Row: Single record
• • Column: Attribute
• • Primary Key
• • Foreign Key
ISO SQL Data Types
• ISO SQL defines standard data types for
compatibility.
• Numeric: INT, SMALLINT, DECIMAL
• Character: CHAR, VARCHAR
• Date/Time: DATE, TIME, TIMESTAMP
• Boolean: BOOLEAN
SQL Identifiers
• Identifiers are names of database objects.
• Rules:
• • Start with a letter
• • Can contain letters, digits, underscore
• • Cannot use reserved keywords
• Examples: Student, StudentID
SQL Scalar Data Types
• Scalar data types store single values.
• Numeric: INT, DECIMAL
• Character: CHAR, VARCHAR
• Date/Time: DATE, TIMESTAMP
• Boolean: TRUE / FALSE