loading

SQL Syntax

SQL Statements

SQL statements are used for the majority of tasks that need to be completed on a database.

Simple-to-understand keywords make up SQL statements.

A table called “Customers” has all of its records returned by the SQL statement that follows:

Example

Select all records from the Customers table:

				
					SELECT * FROM Customers;
				
			

We will cover every topic regarding the various SQL statements in this course.

Database Tables

Most frequently, a database has one or more tables. Every table has a name (such as “Customers” or “Orders”) and is made up of records (rows) that hold data.

The well-known Northwind sample database, which is available in MS Access and MS SQL Server, will be used in this tutorial.

CustomerID CustomerName ContactName Address City PostalCode Country
1

Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany
2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico
3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico
4

Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK
5 Berglunds snabbköp Christina Berglund Berguvsvägen 8 Luleå S-958 22 Sweden

The aforementioned table has seven columns (CustomerID, CustomerName, ContactName, Address, City, PostalCode, and Country) and five records (one for each customer).

Keep in Mind That...

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

In this tutorial we will write all SQL keywords in upper-case.

Semicolon after SQL Statements?

Every SQL statement must terminate with a semicolon in certain database systems.

In database systems that let the execution of several SQL statements in a single request to the server, semicolons are typically used to divide each SQL statement.

Semicolons will be used at the conclusion of each SQL statement in this course.

Some of The Most Important SQL Commands

  • SELECT – extracts data from a database
  • UPDATE – updates data in a database
  • DELETE – deletes data from a database
  • INSERT INTO – inserts new data into a database
  • CREATE DATABASE – creates a new database
  • ALTER DATABASE – modifies a database
  • CREATE TABLE – creates a new table
  • ALTER TABLE – modifies a table
  • DROP TABLE – deletes a table
  • CREATE INDEX – creates an index (search key)
  • DROP INDEX – deletes an index
Share this Doc

SQL Syntax

Or copy link

Explore Topic