Chapter 6 Basic SQL

<aside> <img src="/icons/map-pin_gray.svg" alt="/icons/map-pin_gray.svg" width="40px" /> Feel free to open SQL Developer alongside. You click the copy button located on the top-right of the code and run/modify it on your own computer.

</aside>

SQL is a comprehensive database language. It has statements for data definitions, queries, and updates. It’s both a DDL and a DML.

We will cover the different commands in the following sections. Before doing that, let’s quickly go over the basic data types available for attributes.

Attribute Data Type

These define what type value the column can hold.

<aside> <img src="/icons/map-pin_gray.svg" alt="/icons/map-pin_gray.svg" width="40px" /> Note that some data types that exists in one relational DBMS might use a slightly different syntax for the other. For example, DB2 provides a SMALLINT data type, whereas in Oracle, we just use NUMBER(size). The ones listed below will be applicable to Oracle.

</aside>

In particular for SQL, they can be categorized into the five data types. However, we will cover only give four of them, as we’ll not discuss bit string.

  1. Numeric
  1. Character string
  1. Date
  1. Time