SQL Syntax OR SQL Command

SQL Syntax OR SQL Command


Demo Database Tables

A database most often contains one or more tables. Each table is identified by a name (e.g. "Customers" or "Orders"). Tables contain records (rows) with data.

Here, we have taken a sample table called as "Books".

Sample "Books" Table

BookId BookName BookPrice RelYear Domain AuthorName
1 Learn SQL 124 2011 Security Azaghu Varshith
2 Sql for dummies 216 2014 Database Geetha
3 Sql Database Design 140 2003 Database Varshini Kutty
4 Sql Quick Reference 275.85 2003 Programming Padmavathi
5 Getting started with SQL 184 2004 Administration Bala Murugan
6 Sql and relation theory 100 2010 Database Varshini Kutty




SQL Statements

Most of the actions you need to perform on a database are done with SQL statements.

SQL statements are dependent on text lines. We can place a single SQL statement on one or multiple text lines.

All the SQL statements start with any of the keywords like SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW and all the statements end with a semicolon (;).

The following SQL statement selects all the records in the "Customers" table:


SELECT * FROM Books;

Keep in Mind That...

SQL is NOT case sensitive: select is the same as SELECT

All the examples given in this tutorial have been tested with MySQL server.


Semicolon after SQL Statements?

Some database systems require a semicolon at the end of each SQL statement.

Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server.





Some of The Most Important SQL Commands

Command Name Description
SELECT Extracts data or records from a database table
INSERT INTO To create new data or records into a database table
UPDATE To update existing data or records in a database table
DELETE To delete or remove existing data or records in a database table
CREATE TABLE To create a new database table
ALTER TABLE To modify or change the database table structure
CREATE DATABASE To create a new user defined database
DROP DATABASE To delete or remove existing user defined database