SQL syntax

Data in relational databases is stored in tables that are largely independent of each other. You can easily add, delete, or change data in a table without affecting the data in the other tables, provided that the affected table is not a parent of any of the other tables.

The table below contains three records (one for each customer) and six columns (id, name, address, city, state, and zip).

+----+------------+-------------------+---------+-------+-------+
| id | name       | address           | city    | state | zip   |
+----+------------+-------------------+---------+-------+-------+
|  1 | Bill Smith | 123 Main Street   | Hope    | CA    | 98765 |
|  2 | Mary Smith | 123 Dorian Street | Harmony | AZ    | 98765 |
|  3 | Bob Smith  | 123 Laugh Street  | Humor   | CA    | 98765 |
+----+------------+-------------------+---------+-------+-------+

SQL Statements

SQL statements are made up of plain English terms. These terms are known as keywords, and every SQL statement is made up of one or more keywords. The SQL statement that you’ll probably use most frequently is the SELECT statement.

SQL is not case sensitive, which means SELECT and select have same meaning in SQL syntax.

 

Here is a list of the most important SQL commands:

  • SELECT: it extracts data from a database.
  • UPDATE: it updates data in database.
  • DELETE: it deletes data from a database.
  • CREATE TABLE: it creates a new table.
  • ALTER TABLE: it is used to modify the table.
  • DROP TABLE: it deletes a table.
  • CREATE DATABASE: it creates a new database.
  • ALTER DATABASE: It is used to modify a database.
  • INSERT INTO: it inserts new data into a database.
  • CREATE INDEX: it is used to create an index (search key).
  • DROP INDEX: it deletes an index.
Geek University 2022