What is SQL syntax?
What is SQL syntax?
The SQL syntax is quite an easy one to grasp. Most of the actions you need to perform are done with a SQL statement. SQL is followed by unique set of rules and guidelines called Syntax. This tutorial gives you a quick start with SQL by listing all the basic SQL Syntax.
Keep in Mind That SQL is not case sensitive. Different programmers have their own preferences. For readability purposes, many SQL programmers prefer to use uppercase for SQL commands and lowercase for everything else.
The SQL syntax allows you to include line breaks at logical points without it breaking the statement. Some database systems require that you use a semicolon at the end of each SQL statement.
SQL categories:
SQL is divided into two main categories. Data Manipulation Language (DML), and Data Definition Language (DDL).
Data Manipulation Language (DML)
DML enables you to work with the data that goes into the database. DML is used to insert, select, update, and delete records in the database. Many of your SQL statements will begin with one of the following commands:
- SELECT – Retrieves data from the database
- INSERT – Inserts new data into the database
- UPDATE – Updates existing data in the database
- DELETE – Deletes existing data from the database
Data Definition Language (DDL)
You may also occasionally need to create or drop a table or other datbase object. SQL enables you to do this programatically using DDL.
Examples of DDL commands:
- CREATE DATABASE – Creates a new database
- ALTER DATABASE – Modifies the database
- DROP DATABASE – Drops (deletes) a database
- CREATE TABLE – Creates a new table
- ALTER TABLE – Modifies the table
- DROP TABLE – Drops (deletes) a table
These are just some of the object classes that can be defined using DDL. As you can probably guess, the syntax is generally the same for any object, although, each object will have properties specific to that object class.
As you can see, the SQL syntax is quite simple. It is also very powerful syntax.