8 - Introduction to SQL

Cards (24)

  • Structured Query Language
    Standard language for creating and querying relational databases
  • Classification of SQL commands
    1. Data Definition Language (DDL)
    2. Data Manipulation Language (DML)
    3. Data Control Language (DCL)
  • Data Definition Language (DDL)
    used to create, alter, and drop tables
  • Data Manipulation Language (DML)
    core commands of SQL used for updating, inserting, modifying, and querying the data in the database
  • Data Control Language (DCL)
    used to grant or revoke privileges to access the databases or particular objects within the databases; used to store or remove transactions that would affect the databases
  • DML Command
    1. Select
    2. Insert
    3. Update
    4. Delete
  • Select
    allows users to query the data contained in the tables based on certain criteria
  • Structure of an SQL Query
    1. Select
    2. From
    3. Where
    4. Group By
    5. Having
    6. Order By
  • Select
    columns or attributes
    literals
    arithmetic expression
    scalar or column functions
  • From
    tables or views
  • WHERE
    condition for row selection
  • ORDER BY
    sort key
  • Select *
    From Product T;

    means Select all attributes/rows FROM Product_T table.
  • USING BOOLEAN OPERATORS WITH SELECT CLAUSE (IN ORDER)
    1. NOT
    2. AND
    3. OR
  • AND
    joins 2 or more conditions; only when all conditions are TRUE
  • OR
    joins 2 or more conditions; when ANY conditions are TRUE
  • NOT
    negates an expression
  • IN
    used in the WHERE clause, specify that a particular column value must match one of the values in a list.
  • NOT
    inverts expression
  • BETWEEN
    allows user to specify MINIMUM and MAXIMUM VALUE on 1 line (RANGE)
  • BETWEEN is inclusive
  • LIKE
    allows for searches for particular values
  • %
    multiple character wildcard
  • _
    single character wildcard