Popular
Electronics & Technology Blog
Vijayendra Singh
-
SQL Tutorial, Basics of SQL
-
What is SQL
SQL means Structured Query Language. With help of SQL we can access and manipulate databases. SQL executes queries and receives data from a database. In SQL we can insert, update and delete records in a database. We can create new tables, views and stored procedures in a databases & can set permissions on these tables, procedures, and views.
How to use SQL for websites
For using SQL in our website we need to have a program like RDBMS Relational Database Management System like MS Access, MySQL, SQL Server plus a server side scripting language like ASP or PHP. Also we must require basic knowledge of HTML & CSS.
The Data in RDBMS is stored in tables. SQL Language is not case sensitive.
SQL can be divided into two parts:
The Data Manipulation Language (DML) & Data Definition Language (DDL).
The query and update commands form the DML part of SQL:
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.
The DDL part of SQL allows database tables to be created or deleted.
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.
DROP INDEX - deletes an index.
Some Basic SQL Commands
The SQL SELECT statement extracts data from one or more database tables or views.
SELECT Colname1, Colname2, …
FROM Table1The SQL INSERT INTO inserts new data to database :
INSERT INTO Country (State, People, Date)
VALUES ('MP', 20, '15/12/2006')The SQL UPDATE updates data of database:
UPDATE Table1
SET Column1 = Value1, Column2 = Value2, …The SQL DELETE deletes data from database.
DELETE FROM Country
WHERE People = 20The SQL syntax for CREATE TABLE is
CREATE TABLE "NameofTable"
("column 1" "datatype",
"column 2" "datatype",
... )
for eg.
CREATE TABLE employee
(First_Name char(25),
Last_Name char(25),
Address char(25),
City char(25),
Country char(25),
.....