SQL BASICS Database Management System

SQL BASICS Database Management System

SQL BASICS

What is SQL?

  • SQL stands for Structured Query Language
  • SQL lets you access and manipulate databases
  • SQL is an ANS (American National Standards Institute) standard

 

What Can SQL Do?

  • SQL can execute queries against a database
  • SQL can retrieve data from a database
  • SQL Can insert records in a databaSe
  • Can update records in a database
  • SQL can delete records from a database
  • SQL Can Create new databases
  • SQL Can Create new tables in a database
  • SQL can Create stored procedures in a database
  • SQL can Create views in a database
  • SQL can set permissions on tables, procedures, and views

Although SQL is an ANSI (American National Standards Institute) Standard, there are many different versions of the SQL language.

However, to be compliant with the ANSI standard, they all support at least the major commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) in a similar manner.

 

Note :  Most of the SQL database programs also have their own proprietary extensions in addition to the

SQL standard.

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.

Below is an example of a table called “Employee”:

SQL BASICS Database Management System

The table above contains three records (one for each person) and five columns (SLNO, LastName,

FirstName, Address, and City).

The following SQL statement will select all the records in the “Employee” table :

SELECT * FROM Employee;

Now we want to select the Content of the Columns named “LastName” and “FirstName” from the table “Employee” mentioned above.

We use the following SELECT statement :

SELECT LastName, FirstName FROM Employee

The result-set will look like this :

SQL BASICS Database Management System

Now we want to select all the columns from the “Employee” table.

We use the following SELECT statement :

SELECT * FROM Persons

The result – Set Will look like this :

SQL BASICS Database Management System

Some Important Points

  • SQL is not case sensitive in general (except for searching).
  • 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.

Capabilities of SQL SELECT Statements

A SELECT statement retrieves information from the database. Using a SELECT statement, you can do the following :

Projection :  You can use the projection capability in SQL to choose the columns in a table that you want returned by your query. You can choose as few or as many Columns of the table as you require.

Selection :  You can use the selection capability in SQL to choose the rows in a table that you want returned by a query. You can use various criteria to restrict the rows that you see.

Joining : You can use the join capability in SQL to bring together data that is stored in different tables by creating a link between them.