SQL Constraints and Commands

  • Constraints List

    Here are a few commonly used constraints:

    ConstraintDescription
    NOT NULLvalues cannot be NULL
    UNIQUEvalues cannot match any older value
    PRIMARY KEYused to uniquely identify a row
    FOREIGN KEYreferences a row in another table
  • SQL can perform many tasks such as

    • retrieving data
    • creating tables
    • inserting and changing rows
    • deleting tables
    • and so on

    Due to the wide range of tasks SQL can perform, it can be overwhelming to remember all the commands.

    To make it easier to understand different SQL commands, we can categorize SQL commands into several sublanguages:

  • Data Query Language (DQL) - SELECT
  • Data Manipulation Language (DML) - INSERTUPDATEDELETE
  • Data Definition Language (DDL) - CREATE TABLECREATE DATABASEALTER TABLEDROP TABLE
  • Data Control Language (DCL) - GRANTREVOKE
  • Transaction Control Language (TCL) - SAVEPOINTROLLBACKCOMMIT

Comments