SQL -Structured Query Language - Overview - SQL Syntax Tutorial
SQL queries are written using a unique set of rules and regulations called syntax. Some of the basic rules are –
- SQL is not case sensitive. But it better to write it in either lowercase or uppercase.
- SQL statement starts with any of the SQL command/keywords like SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW, etc., and ends with a semicolon ‘; ‘.
Some of the syntax for better understanding
-
select * from regions;
-
SELECT * FROM REGIONS;
-
select * From REGIONS;
-
select * From REGIONS; select * From REGIONS;
-
select * From REGIONS select * From REGIONS;
The above example will clearly show how the query is not case sensitive.
- In line 1, the whole statement is in lowercase. still, it gives the proper output.
- In line 2, the whole statement is in uppercase. still, it gives the proper output.
- In line 3, the statement is a mixture of uppercase and lowercase, still, it gives proper output
- In line 4, An important part is there is two statement, which has been separated using a semicolon ‘; ‘.
- In line 5, An important part is there is two statement, which has been separated without using a semicolon ‘; ‘. A single statement can be run without a semicolon. But if there are two statements without separating with the semicolon, then it will give an error.
Hence semicolon ‘; ‘ is very important in writing multiple SQL queries.
select * from regions
The above query or statement is written singly. Hence it can run without the use of the semicolon.