SQL (pronounced “ess-que-el”) stands for Structured Query Language. SQL is used to communicate with a database. According to ANSI (American National Standards Institute), it is the standard language for relational database management systems.It is designed over relational algebra and tuple relational calculus. SQL comes as a package with all major distributions of RDBMS.
Data definition Language
SQL uses the following set of commands to define database schema:
Creates new databases, tables and views from RDBMS
Create database shiksha360;
Create table article;
Create view for_students;
Drop commands deletes views, tables and databases from RDBMS
Drop object_type object_name;
Drop database shiksha360;
Drop table article;
Drop view for_students;
Modifies database schema.
Alter object_type object_name parameters;
Alter table article add subject varchar;
This command adds an attribute in relation article with name subject of string type.
Data Manipulation Language
SQL is equipped with data manipulation language. DML modifies the database instance by inserting, updating and deleting its data. DML is responsible for all data modification in databases. SQL contains the following set of command in DML section:
These basic constructs allows database programmers and users to enter data and information into the database and retrieve efficiently using a number of filter options.
This is one of the fundamental query command of SQL. It is similar to projection operation of relational algebra. It selects the attributes based on the condition described by WHERE clause.
This clause takes a relation name as an argument from which attributes are to be selected/projected. In case more than one relation names are given this clause corresponds to Cartesian product.
This clause defines predicate or conditions which must match in order to qualify the attributes to be projected.
Select author From article Where age > 50;
This command will project names of author’s from book_author relation whose age is greater than 50.
This command is used for inserting values into rows of table (relation).
INSERT INTO table (column1 [column2, column3 ... ]) VALUES (value1 [value2, value3 ... ])
INSERT INTO table VALUES (value1, [value2, ... ])
INSERT INTO article(Author, Subject) VALUES ("anonymous", "computers");
This command is used for updating or modifying values of columns of table (relation).
UPDATE table_name SET column_name = value [column_name = value ...] [WHERE condition]
UPDATE article SET Author="webmaster" WHERE Author="anonymous";
This command is used for removing one or more rows from table (relation).
DELETE FROM table_name [WHERE condition];
DELETE FROM article WHERE Author="unknown";