Introduction to SQL
SQL stands for Structured Query Language.
It is the standard for interaction with the databases.
SQL features an English-like syntax which is easy to learn and allows complex query formation by feeding results of one query into another.
Some features of SQL are:
Some examples of the SQL syntax:
CREATE TABLE People ( id INT, age INT, first_name VARCHAR(50), last_name VARCHAR(50), birthday DATE NOT NULL, PRIMARY KEY (id) ); /* Schema of a table can be modified after creation */ ALTER TABLE People ADD zipcode NUMBER(3) NOT NULL; /* Data is read by 'Select' queries as follows */ Select * from people where age >= 30; Select * from people where age between 30 and 50; Select * from people where age > 30 and first_name = 'Bob'; /* Queried data can be sorted by making use of the 'Order by' clause */ Select first_name, age from people order by age desc; /* Data can be grouped on any column. For example: */ Select age, count(*) from people group by age; /* This query returns two columns per row. */ /* First column in each row will be age and second column would be the number of people having that age. */ /* A single query can have subqueries as expressions. For example: */ /* This query returns name and age of all the people whose age equals the average age of people in the table. */ Select first_name as fname, last_name as lname, age from people where age = (Select avg(age) from people) /* Unwanted tables can be deleted easily */ Drop table people;
|Email:||(Your email is not shared with anybody)|