codingstreets
Search
Close this search box.

Get Started: SQL Syntax

In This Article, You Will Know About SQL Syntax.

SQL Syntax – Before moving ahead, let’s know a bit about SQL Introduction.

Table of Contents

Database Tables

A database usually comprises at least one table. The tables are identified with the name (e.g., “ID” or “Class”). Tables have records (rows) that contain information.

Below is an example of a database table named “details”:

Id

name

class

section_id

1

Alex

5

1

2

Rolex

6

2

3

Salex

7

2

4

Lelex

8

3

5

Kelex

9

5

The table above contains five records (one for each name) and four columns (Id, name, class, section).

SQL Statements

Most of the tasks you have to do in a database are accomplished using SQL statements.

Following SQL statement is a search for all records of the “details” table:

				
					SELECT * FROM details
				
			

Note: SQL keywords are NOT case sensitive: select is the same as SELECT

So, the above code is correct in lowercase as well.

				
					select * from details
				
			

SQL Statements – Semicolon?

Some databases require a semicolon to be added at the end of every SQL statement.

The semicolon is the preferred method to distinguish every SQL statement in databases which allows multiple SQL statements to execute on the same request on the server.

Important SQL Commands

  • SELECT – Use to extract data from a database
  • UPDATE – Use to update data in a database
  • DELETE – Use to delete data from a database
  • INSERT INTO – Use to insert new data into a database
  • CREATE DATABASE – Use to create a new database
  • ALTER DATABASE – Use to modify a database
  • CREATE TABLE – Use to create a new table
  • ALTER TABLE – Use to modify a table
  • DROP TABLE – Use to delete a table
  • CREATE INDEX – Use to create an index (search key)
  • DROP INDEX – Use to delete an index

If you find anything incorrect in the above-discussed topic and have further questions, please comment below.

Connect on:

Recent Post

Popular Post

Top Articles

Archives
Categories

Share on