Loading, please wait...

SQL Syntax

Introduction To SQL Syntax

 

Introduction:

In this article, you will learn what syntax is and how many types of syntax are used in SQL.

In SQL, each query has a unique syntax. Every syntax starts with the keyword and ends with semicolon (;). With the help of the syntax, we use our data, which is stored in SQL database. SQL is case insensitive and it means we can write any keyword in both capital and small letters like INSERT or insert.

 

Here, we have some SQL queries and there syntax.

 

SQL Create Database Statement -

Syntax : create database database_name;

 

SQL Drop Database Statement -

Syntax : drop database database_name;

 

SQL USE Statement -

Syntax : use database_name;

 

SQL Select Statement -

Syntax : Select column1, column2....columnN from table_name;

 

SQL Create table Statement -

Syntax : create table table_name(

column1 datatype,

column2 datatype,

column3 datatype,

.....

Primary Key( column_name )

);

 

SQL Insert into Statement -

Syntax : insert into table_name( column1, column2....columnN) values ( value1, value2....valueN);

 

SQL Update Statement-

Syntax : update table_name set column1=value1, column2=value2....columnN=valueN [where condition];

 

SQL Delete Statement-

Syntax : delete from table_name where [condition];

 

SQL Drop Table Statement -

Syntax : drop table table_name;

 

SQL where Clause -

Syntax : select column1, column2....columnN from table_name where condition;

 

SQL AND/OR Clause -

Syntax : select column1, column2....columnN from table_name where (condition) {AND|OR} (condition);

 

SQL Between Clause -

Syntax : select column1, column2....columnN from table_name where column_name between value1 and value2;

 

SQL IN Clause -

Syntax : select column1, column2....columnN from table_name where column_name in (value1, value2,...valueN);

 

SQL Distinct Clause -

Syntax : select distinct column1, column2....columnN from table_name;

 

SQL Order By Clause -

Syntax : select column1, column2....columnN from table_name where condition order by column_name {asc|desc};

 

SQL Group By Clause -

Syntax : select sum(column_name) from table_name where condition group by column_name;

 

SQL Having Clause -

Syntax : select sum(column_name) from table_name where condition group by by column_name having (condition);

 

SQL Like Clause -

Syntax : select column1, column2....columnN from table_name where column_name like [pattern];

 

SQL Count Clause -

Syntax : select count (column_name) from table_name where condition;

 

SQL Create Index Statement -

Syntax : create unique index index_name on table_name ( column1, column2,...columnN);

 

SQL Drop Index Statement -

Syntax : alter table table_name drop index index_name;

 

SQL DESC Statement -

Syntax : desc table_name;

 

SQL Truncate Table Statement-

Syntax : truncate table table_name;

 

SQL Alter Table Statemen -

Syntax : alter Table table_name [add|drop|modify] column_name [data_type];

 

SQL Alter Rename Table Statement -

Syntax : alter table table_name rename to new_table_name;

 

SQL COMMIT Statement -

Syntax : commit;

 

SQL ROLLBACK Statement -

Syntax : rollback;

 

Summary:
Thus, we learned that about the different types of syntax in SQL Server.